/// <summary> /// 开启加载一个配置。 /// </summary> /// <param name="connName">Conn的名称</param> /// <param name="connPath">Conn指向的路径</param> /// <returns></returns> public static string Start(string connName, string connPath) { lock (o) { string path = AppConfig.RunPath + connPath; string json = JsonHelper.ReadJson(path); if (string.IsNullOrEmpty(json)) { return(connName); } WatchConfig config = JsonHelper.ToEntity <WatchConfig>(JsonHelper.GetValue(json, connName)); if (config != null && !string.IsNullOrEmpty(config.Master)) { AppConfig.SetConn(connName, config.Master); if (!string.IsNullOrEmpty(config.Backup)) { AppConfig.SetConn(connName + "_Bak", config.Backup); } if (config.Slave != null && config.Slave.Length > 0) { for (int i = 0; i < config.Slave.Length; i++) { AppConfig.SetConn(connName + "_Slave" + (i + 1), config.Slave[i]); } } if (!watchList.ContainsValue(connPath)) { IOWatch.On(path, delegate(FileSystemEventArgs e) { fsy_Changed(e); }); } if (!watchList.ContainsKey(connName)) { watchList.Add(connName, connPath); } return(config.Master); } } return(connName); }