private Properties readConfigSection(String sectionName, Properties defaults) { var properties = new Properties(); NameValueCollection config = ConfigurationManager.GetSection("hermes/" + sectionName) as NameValueCollection; if (config != null) { foreach (string k in config) { properties.SetProperty(k, config[k]); } } return properties; }
public void Initialize() { producerDefault = readConfigSection(PRODUCER_DEFAULT_SECTION); consumerDefault = readConfigSection(CONSUMER_DEFAULT_SECTION); GlobalDefault = readConfigSection(GLOBAL_SECTION); Env? resultEnv = Hermes.GetEnv(); NameValueCollection config = ConfigurationManager.GetSection("hermes/global") as NameValueCollection; if (config != null && config["env"] != null) { Env newEnv = (Env)Enum.Parse(typeof(Env), config["env"].ToUpper()); if (resultEnv != null && newEnv != resultEnv) { throw new Exception(string.Format("Inconsist Hermes env {0} {1}", resultEnv, newEnv)); } else { resultEnv = newEnv; } } if (resultEnv == null) { throw new Exception("Hermes env is not set"); } env = resultEnv.Value; env2MetaDomain.Add(Env.LOCAL, GlobalDefault.GetProperty("local.domain", "meta.hermes.local")); // TODO use real dev&lpt domain when get dev&lpt domain env2MetaDomain.Add(Env.DEV, GlobalDefault.GetProperty("dev.domain", "10.3.8.63")); env2MetaDomain.Add(Env.LPT, GlobalDefault.GetProperty("lpt.domain", "10.2.5.133")); env2MetaDomain.Add(Env.FAT, GlobalDefault.GetProperty("fat.domain", "meta.hermes.fws.qa.nt.ctripcorp.com")); env2MetaDomain.Add(Env.FWS, GlobalDefault.GetProperty("fws.domain", "meta.hermes.fws.qa.nt.ctripcorp.com")); env2MetaDomain .Add(Env.UAT, GlobalDefault.GetProperty("uat.domain", "meta.hermes.fx.uat.qa.nt.ctripcorp.com")); env2MetaDomain.Add(Env.PROD, GlobalDefault.GetProperty("prod.domain", "meta.hermes.fx.ctripcorp.com")); env2MetaDomain.Add(Env.PRD, GlobalDefault.GetProperty("prd.domain", "meta.hermes.fx.ctripcorp.com")); log.Info(string.Format("Meta server domains: {0}", env2MetaDomain)); }