예제 #1
0
        /// <summary>
        /// Loads instance properties from XML.
        /// </summary>
        /// <param name="itemNode">Node to load XML from</param>
        /// <returns>true if sucessfully loaded from XML</returns>
        public bool Load(XmlNode fileNameNode)
        {
            // Loop through sub-nodes
            foreach (XmlNode propNode in fileNameNode.ChildNodes)
            {
                // Get element/property type
                XmlElements element; ;
                if (!Enum.TryParse<XmlElements>(propNode.Name, out element))
                    continue;

                // Get value string
                string value = propNode.InnerText;

                // Load value into appropriate property
                switch (element)
                {
                    case XmlElements.NumProcessingThreads:
                        int numProc;
                        if(int.TryParse(value, out numProc))
                            this.NumProcessingThreads = numProc;
                        break;
                    case XmlElements.NumSimultaneousSearches:
                        int numSearch;
                        if(int.TryParse(value, out numSearch))
                            this.NumSimultaneousSearches = numSearch;
                        break;
                    case XmlElements.DefaultMovieDatabase:
                        MovieDatabaseSelection movieDb;
                        if (Enum.TryParse<MovieDatabaseSelection>(value, out movieDb))
                            this.DefaultMovieDatabase = movieDb;
                        break;
                    case XmlElements.DefaultTvDatabase:
                        TvDataBaseSelection tvDb;
                        if (Enum.TryParse<TvDataBaseSelection>(value, out tvDb))
                            this.DefaultTvDatabase = tvDb;
                        break;
                    case XmlElements.TorrentDirectory:
                        this.TorrentDirectory = value;
                        break;
                    case XmlElements.PreferredTorrentQuality:
                        TorrentQuality torrentQual;
                        if (Enum.TryParse<TorrentQuality>(value, out torrentQual))
                            this.PreferredTorrentQuality = torrentQual;
                        break;
                    case XmlElements.TorrentDownload:
                        TorrentDownload torrentDwnld;
                        if (Enum.TryParse<TorrentDownload>(value, out torrentDwnld))
                            this.TorrentDownload = torrentDwnld;
                        break;
                }
            }

            // Success
            return true;
        }
예제 #2
0
 private static void LogStatus(TorrentDownload download)
 {
     Console.WriteLine($"{download.State} ({download.Progress:P})");
 }
예제 #3
0
 public void Clone(GeneralSettings settings)
 {
     this.NumProcessingThreads = settings.NumProcessingThreads;
     this.NumSimultaneousSearches = settings.NumSimultaneousSearches;
     this.DefaultMovieDatabase = settings.DefaultMovieDatabase;
     this.DefaultTvDatabase = settings.DefaultTvDatabase;
     this.TorrentDirectory = settings.TorrentDirectory;
     this.PreferredTorrentQuality = settings.PreferredTorrentQuality;
     this.TorrentDownload = settings.TorrentDownload;
 }