コード例 #1
0
 public void Initialize(Config config)
 {
     // do nothing
 }
コード例 #2
0
 public void Initialize(Config config)
 {
     this._config = config;
     this._cache = Cache.Load();
 }
コード例 #3
0
ファイル: Config.cs プロジェクト: jefim/wooster
        /// <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;
        }
コード例 #4
0
ファイル: MiscActionProvider.cs プロジェクト: jefim/wooster
 public void Initialize(Config config)
 {
     this._config = config;
 }
コード例 #5
0
ファイル: Config.cs プロジェクト: jefim/wooster
 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;
 }