コード例 #1
0
ファイル: ScanManager.cs プロジェクト: a-jackson/tvsorter
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanManager"/> class.
 /// </summary>
 /// <param name="storageProvider">
 /// The storage provider to use.
 /// </param>
 /// <param name="dataProvider">
 /// The data provider to use. 
 /// </param>
 internal ScanManager(IStorageProvider storageProvider, IDataProvider dataProvider)
 {
     this.storageProvider = storageProvider;
     this.dataProvider = dataProvider;
     this.settings = Settings.LoadSettings(storageProvider);
     this.tvShows = TvShow.GetTvShows(storageProvider).ToList();
 }
コード例 #2
0
ファイル: FileManager.cs プロジェクト: a-jackson/tvsorter
 /// <summary>
 /// Initializes a new instance of the <see cref="FileManager"/> class. Initialises a new instance of the <see cref="FileManager"/> class.
 /// </summary>
 /// <param name="storageProvider">
 /// The storage provider.
 /// </param>
 /// <param name="dataProvider">
 /// The data provider.
 /// </param>
 internal FileManager(IStorageProvider storageProvider, IDataProvider dataProvider)
 {
     this.storageProvider = storageProvider;
     this.settings = Settings.LoadSettings(storageProvider);
     this.scanManager = new ScanManager(this.storageProvider, dataProvider);
 }
コード例 #3
0
 /// <summary>
 /// Loads the settings.
 /// </summary>
 private void LoadSettings()
 {
     this.settings = Settings.LoadSettings();
     this.settings.SettingsChanged += (sender, e) => { this.SubDirectories = this.LoadSubDirectories(); };
     this.SubDirectories = this.LoadSubDirectories();
 }
コード例 #4
0
        /// <summary>
        /// Loads the settings from the specified provider.
        /// </summary>
        /// <param name="provider">
        /// The provider to load the settings from.
        /// </param>
        /// <returns>
        /// The new settings object.
        /// </returns>
        internal static Settings LoadSettings(IStorageProvider provider)
        {
            var settings = new Settings();
            try
            {
                provider.LoadSettings(settings);

                // Remove the event handler before adding it incase the
                // handler has been added before.
                provider.SettingsSaved -= settings.OnSettingsSaved;
                provider.SettingsSaved += settings.OnSettingsSaved;
            }
            catch (IOException)
            {
                // Settings file does not exist. Use default settings.
                settings.SetDefault();
            }

            return settings;
        }
コード例 #5
0
ファイル: Xml.cs プロジェクト: a-jackson/tvsorter
        /// <summary>
        /// Saves the specified settings into the XML file.
        /// </summary>
        /// <param name="settings">
        /// The settings to save. 
        /// </param>
        public void SaveSettings(Settings settings)
        {
            if (this.document.Root == null)
            {
                throw new XmlException("XML is invalid.");
            }

            XElement settingsNode = this.document.Root.Element(GetName("Settings"));
            if (settingsNode == null)
            {
                throw new XmlException("Xml is invalid");
            }

            settingsNode.ReplaceWith(settings.ToXml());
            this.document.Save(XmlFile);
            this.OnSettingsSaved();
        }
コード例 #6
0
ファイル: Xml.cs プロジェクト: a-jackson/tvsorter
        /// <summary>
        /// Reads the settings from the XML file.
        /// </summary>
        /// <param name="settings">
        /// The settings to set from the XML.
        /// </param>
        public void LoadSettings(Settings settings)
        {
            if (this.document.Root == null)
            {
                throw new XmlException("XML is invalid.");
            }

            XElement settingsNode = this.document.Root.Element(GetName("Settings"));
            if (settingsNode == null)
            {
                throw new XmlSchemaException("The XML file is invalid.");
            }

            settings.FromXml(settingsNode);
        }