public void Initialize(Config config) { // do nothing }
public void Initialize(Config config) { this._config = config; this._cache = Cache.Load(); }
/// <summary> /// Loads config from all places - first tries the user config path then uses the default config path. /// </summary> /// <returns></returns> public static Config Load() { #if DEBUG return new Config(); #endif Config config = null; var configPath = GetRealConfigPath(); try { config = LoadConfig(configPath); } catch (Exception ex) { // Failed - show user a message. MessageBox.Show(string.Format("Failed to load config from path '{0}'; will use default configuration.\r\n\r\nError message: \r\n{1}", configPath, ex.Message)); } //var defaultConfigPath = GetDefaultConfigPath(); //// Try loading user config path //if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.ConfigFilePath)) //{ // var userConfigPath = Properties.Settings.Default.ConfigFilePath; // try // { // config = LoadConfig(userConfigPath); // } // catch (Exception ex) // { // // Failed - show user a message. // MessageBox.Show(string.Format("Failed to load config from path '{0}'; will use default configuration.\r\n\r\nError message: \r\n{1}", userConfigPath, ex.Message)); // } //} // If still no config - use the default config if (config == null) { config = new Config(); config.Save(); } return config; }
public void Initialize(Config config) { this._config = config; }
private static Config LoadConfig(string configPath) { var config = new Config(); var serializer = new XmlSerializer(typeof(Config)); try { using (var reader = XmlTextReader.Create(configPath)) { config = (Config)serializer.Deserialize(reader); } } catch (Exception ex) { } return config; }