/// <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; }
private static void LogStatus(TorrentDownload download) { Console.WriteLine($"{download.State} ({download.Progress:P})"); }
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; }