/// <summary>
 /// 添加或更新配置项:如果不存在,则添加到configType4NewAdded指定类型的位置。
 /// </summary>
 /// <param name="key">配置项对应的Key键。</param>
 /// <param name="configValue">配置项的新值。</param>
 /// <param name="configType4NewAdded">新增配置项的类型。</param>
 /// <returns>更新结果。</returns>
 public ConfigOperationResult AddOrUpdateConfig(string key,
                                                string configValue, AppConfigType configType4NewAdded)
 {
     if (this.collection.ContainsKey(key))
     {
         return(UpdateConfig(key, configValue));
     }
     else
     {
         AppConfigData tmpAppData = new AppConfigData()
         {
             ConfigType = configType4NewAdded,
             Key        = key,
             Value      = configValue,
         };
         if (configType4NewAdded.IsRegistryConfig())
         {
             ////RegEditHelp.WriteRegedit(key, configValue);
             throw new NotSupportedException("暂不支持注册表配置。");
         }
         else
         {
             Configuration config = GetConfigurationInstance(configType4NewAdded);
             config.AppSettings.Settings.Add(key, configValue);
             RefreshConfigurationFile(config);
         }
         this.collection.Add(key, tmpAppData);
     }
     return(ConfigOperationResult.Failed);
 }
        /// <summary>
        /// 将指定键-值配置对添加到缓存。
        /// </summary>
        /// <param name="key"></param>
        /// <param name="configValue"></param>
        /// <param name="configType"></param>
        private void AddConfig2Buffer(string key, string configValue, AppConfigType configType)
        {
            if (this.collection.ContainsKey(key))
            {
                var conflictConfig = this.collection[key];
                //LoggingService.Info(string.Format("更新冲突的配置项:{0}-{1}-{2}-->{3}-{4}-{5}。",
                //    conflictConfig.ConfigType, conflictConfig.Key,
                //    conflictConfig.Value, configType, key, configValue));

                if (conflictConfig.ConfigType != configType)
                {
                    var oldConfig = new AppConfigData()
                    {
                        ConfigType = conflictConfig.ConfigType,
                        Key        = conflictConfig.Key,
                        Value      = conflictConfig.Value,
                    };
                    conflictConfig.SetConfigType(configType);
                }
                conflictConfig.SetValue(configValue);
                return;
            }

            if (string.IsNullOrEmpty(configValue))
            {
                this.collection.Add(key, new AppConfigData()
                {
                    ConfigType = configType,
                    Key        = key,
                    Value      = AppConfigData.NullValue,
                });
            }
            else
            {
                this.collection.Add(key, new AppConfigData()
                {
                    ConfigType = configType,
                    Key        = key,
                    Value      = configValue,
                });
            }
        }