Пример #1
0
 public ConnStringManager()
 {
     if (this.cache == null)
     {
         string xml = ConfigCenterClient.Get("TCBase.Data");
         try
         {
             this.cache = ConfigConvert.XmlToConfig(xml);
         }
         catch (Exception ex)
         {
             Log.LogMessage("TCBase.Data", "数据库配置文件转换失败", LogType.Error, true, ex, (object)new
             {
                 configInfo = xml
             });
         }
     }
     ConfigCenterClient.ConfigChanged += new EventHandler <ConfigDataEventArgs>(this.ConfigCenterClient_ConfigChanged);
 }
Пример #2
0
        private void ConfigCenterClient_ConfigChanged(object sender, ConfigDataEventArgs e)
        {
            if (!e.ConfigChangeDictionary.ContainsKey(AppProfile.AppName))
            {
                return;
            }
            List <ConfigData>      addList    = e.ConfigChangeDictionary[AppProfile.AppName].AddList;
            Predicate <ConfigData> predicate1 = (Predicate <ConfigData>)(p => p.Key == "TCBase.Data");
            Predicate <ConfigData> match1;

            if (addList.Exists(match1))
            {
                this.UploadCache(ConfigCenterClient.Get("TCBase.Data"));
            }
            List <ConfigData>      updateList = e.ConfigChangeDictionary[AppProfile.AppName].UpdateList;
            Predicate <ConfigData> predicate2 = (Predicate <ConfigData>)(p => p.Key == "TCBase.Data");
            Predicate <ConfigData> match2;

            if (updateList.Exists(match2))
            {
                this.UploadCache(ConfigCenterClient.Get("TCBase.Data"));
            }
        }