using System;
using System.Collections;
using System.Xml;

namespace FantasySolution.FantasyCorrector
{

  public class ReleaseList : XmlDocument
  {
    private string _Description = "";
    private string _ReleaseDate = "";
    private IList _ReleaseFiles;
    private string _ReleaseVersion = "";
    private string _ReleaseReason = "";

    public ReleaseList(string FileNameAll)
    {
      this.Init(FileNameAll);
    }

    public XmlNode FindNode(string xPath)
    {
      return base.SelectSingleNode(xPath);
    }

    public XmlNodeList GetNodeList(string xPath)
    {
      return base.SelectSingleNode(xPath).ChildNodes;
    }

    public string GetNodeValue(string xPath)
    {
      return base.SelectSingleNode(xPath).InnerText;
    }

    private void Init(string FileNameAll)
    {
      try
      {
        this.Load(FileNameAll);
        this._Description = this.GetNodeValue("AutoUpdater/Description");
        this._ReleaseDate = this.GetNodeValue("AutoUpdater/ReleaseDate");
        this._ReleaseVersion = this.GetNodeValue("AutoUpdater/ReleaseVersion");
        this._ReleaseReason = this.GetNodeValue("AutoUpdater/ReleaseReason");
        this._ReleaseFiles = new ArrayList();
        foreach (XmlNode node in this.GetNodeList("AutoUpdater/Releases"))
        {
          ReleaseFile file = new ReleaseFile();
          file.FileName = node.Attributes["FileName"].Value.Trim();
          file.Version = node.Attributes["Version"].Value.Trim();
          file.ReleaseDate = node.Attributes["ReleaseDate"].Value.Trim();
          file.Size = node.Attributes["Size"].Value.Trim();
          this._ReleaseFiles.Add(file);
        }
      }
      catch
      {
      }
    }


    public string Description
    {
      get
      {
        return this._Description;
      }
      set
      {
        this._Description = value;
      }
    }


    public string ReleaseDate
    {
      get
      {
        return this._ReleaseDate;
      }
      set
      {
        this._ReleaseDate = value;
      }
    }

    public IList ReleaseFiles
    {
      get
      {
        return this._ReleaseFiles;
      }
      set
      {
        this._ReleaseFiles = value;
      }
    }


    public string ReleaseVersion
    {
      get
      {
        return this._ReleaseVersion;
      }
      set
      {
        this._ReleaseVersion = value;
      }
    }
    public string ReleaseReason
    {
      get
      {
        return this._ReleaseReason;
      }
      set
      {
        this._ReleaseReason = value;
      }
    }


  }
}
