public void Load() { try { Root = _provider.Load(PathHelper.ConfigurationFilePath); } catch(Exception ex) { // Failed to load configuration file, create a new one in memory Root = new RootAppConfig(); Tracing.Log("AppConfigManager.Load -- Failed to load configuration file: {0}", ex); } // Fix any important values that could have been corrupted for some reason if (Root.Library.SyncServicePort < 80 || Root.Library.SyncServicePort > 65535) Root.Library.SyncServicePort = 53551; if (Root.General.SongPositionUpdateFrequency < 10 || Root.General.SongPositionUpdateFrequency > 100) Root.General.SongPositionUpdateFrequency = 20; if (Root.General.OutputMeterUpdateFrequency < 10 || Root.General.OutputMeterUpdateFrequency > 100) Root.General.OutputMeterUpdateFrequency = 20; if (Root.General.MaximumPeakFolderSize < 10 || Root.General.OutputMeterUpdateFrequency > 1000) Root.General.MaximumPeakFolderSize = 100; if (Root.Audio.BufferSize < 100 || Root.Audio.BufferSize > 5000) Root.Audio.BufferSize = 1000; if (Root.Audio.UpdatePeriod < 100 || Root.Audio.UpdatePeriod > 1000) Root.Audio.UpdatePeriod = 100; }
/// <summary> /// Saves AppConfigManager to file. /// </summary> /// <param name="filePath">Configuration file path</param> /// <param name="config">AppConfigManager object</param> public void Save(string filePath, RootAppConfig config) { Task.Factory.StartNew(() => { lock(_locker) { using (TextWriter textWriter = new StreamWriter(filePath)) { _serializer.Serialize(textWriter, config); } } }); }
public void Save(string filePath, RootAppConfig config) { SaveRecursive(config, "Root."); }
public RootAppConfig Load(string filePath) { var config = new RootAppConfig(); LoadRecursive(config, "Root."); return config; }
public AppConfigManager() { _provider = Bootstrapper.GetContainer().Resolve<IAppConfigProvider>(); Root = new RootAppConfig(); }