public bool Initialize() { try { Config = (Config)ConfigurationManager.GetSection("Config"); log.InfoFormat("Default central config {0}", Config.CentralConfigServerName); ConnectToBrokers(Config.NbDefaultInstanceName); } catch (Exception ex) { return false; } return true; }
public object Create(object parent, object configContext, XmlNode section) { Config _config = new Config(); XmlNode detailNode = null; #region client config section detailNode = section.SelectSingleNode("appDomain"); _config.AppDomain = detailNode.Attributes["value"].Value.Trim().ToUpper(); detailNode = section.SelectSingleNode("appRoot"); _config.AppRoot = detailNode.Attributes["value"].Value.Trim().ToUpper(); detailNode = section.SelectSingleNode("centralConfigConnection"); _config.CentralConfigServerName = detailNode.Attributes["value"].Value.Trim().ToUpper(); detailNode = section.SelectSingleNode("nbInstance"); _config.NbDefaultInstanceName = detailNode.Attributes["value"].Value.Trim(); _config.DbConnections = (Dictionary<string, DbDetail>)ConfigurationManager.GetSection("DbConnections"); #endregion #region sanity checks if (String.IsNullOrEmpty(_config.CentralConfigServerName)) throw (new ApplicationException("Attempted call to ConnectCentralConfig with null connection string.")); log.DebugFormat("Using central config {0}.", _config.CentralConfigServerName); if (_config.DbConnections == null) throw (new ApplicationException("Database connection settings are null.")); log.DebugFormat("Registered {0} database connections.", _config.DbConnections.Count); if (!_config.DbConnections.ContainsKey(_config.CentralConfigServerName)) throw (new ApplicationException(String.Format("Central config connection string is not configured. {0}", _config.CentralConfigServerName))); #endregion _config.Initialize(); return _config; }