using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Serialization; using RainmeterStudio.Storage; namespace RainmeterStudio.Model { /// /// Defines a Rainmeter Studio project /// public class Project { #region Name property private string _name; /// /// Gets or sets the name of the project /// [XmlElement("name")] public string Name { get { return _name; } set { _name = value; if (Root != null) Root.Data = new Reference(Name, Path); } } private string _path; #endregion #region Path property /// /// Gets or sets the file path of this project /// [XmlIgnore] public string Path { get { return _path; } set { _path = value; if (Root != null) Root.Data = new Reference(Name, Path); } } #endregion #region Author property /// /// Gets or sets the author of the project /// [XmlElement("author")] public string Author { get; set; } #endregion #region Version property /// /// Gets or sets the version of the project /// [XmlIgnore] public Version Version { get; set; } /// /// Gets or sets the string representation of the project version /// [XmlElement("version")] public string VersionString { get { return Version.ToString(); } set { Version = new Version(value); } } #endregion #region Auto-load file property /// /// Gets or sets the reference to the file to automatically load at package installation /// [XmlElement("autoLoadFile")] public Reference AutoLoadFile { get; set; } #endregion #region Variable files property /// /// Gets or sets the list of variable files /// [XmlArray("variableFiles")] public List VariableFiles { get; set; } #endregion #region Minimum rainmeter & windows properties /// /// Gets or sets the minimum rainmeter version /// [XmlIgnore] public Version MinimumRainmeter { get; set; } /// /// Gets or sets the string representation of the minimum rainmeter version /// [XmlElement("minimumRainmeter")] public string MinimumRainmeterString { get { return MinimumRainmeter.ToString(); } set { MinimumRainmeter = new Version(value); } } /// /// Gets or sets the minimum Windows version /// [XmlIgnore] public Version MinimumWindows { get; set; } /// /// Gets or sets the string representation of the minimum Windows version /// [XmlElement("minimumWindows")] public string MinimumWindowsString { get { return MinimumWindows.ToString(); } set { MinimumWindows = new Version(value); } } #endregion #region Root property /// /// Gets or sets the root node /// [XmlIgnore] public Tree Root { get; set; } /// /// Gets or sets the serializable root node /// /// Warning: not efficient [XmlElement("root")] public SerializableTree SerializableRoot { get { return Root.AsSerializableTree(); } set { Root = value.AsTree(); } } #endregion #region Constructor /// /// Initializes a project /// public Project() { Root = new Tree(); VariableFiles = new List(); Version = new Version(); MinimumRainmeter = new Version("3.1"); MinimumWindows = new Version("5.1"); } #endregion #region Equals public override bool Equals(object obj) { Project other = obj as Project; if (other == null) return false; bool res = String.Equals(Author, other.Author); res &= Reference.Equals(AutoLoadFile, other.AutoLoadFile); res &= Version.Equals(MinimumRainmeter, other.MinimumRainmeter); res &= Version.Equals(MinimumWindows, other.MinimumWindows); res &= String.Equals(Name, other.Name); res &= Tree.Equals(Root, other.Root); res &= Version.Equals(Version, other.Version); return res; } public override int GetHashCode() { int hash = (Author == null) ? 0 : Author.GetHashCode(); hash = hash * 7 + ((AutoLoadFile == null) ? 0 : AutoLoadFile.GetHashCode()); hash = hash * 7 + ((MinimumRainmeter == null) ? 0 : MinimumRainmeter.GetHashCode()); hash = hash * 7 + ((MinimumWindows == null) ? 0 : MinimumWindows.GetHashCode()); hash = hash * 7 + ((Name == null) ? 0 : Name.GetHashCode()); hash = hash * 7 + ((Root == null) ? 0 : Root.GetHashCode()); hash = hash * 7 + ((Version == null) ? 0 : Version.GetHashCode()); return hash; } #endregion } }