internal SimpleLookupsConfiguration(ISimpleLookupsConfigurationSection configSection) { ConnectionInfos = new List <IConnectionInfo>(); SetDefaults(); if (configSection != null) { var defaultConnectionStringSection = configSection.ConnectionStrings.GetDefault(); if (defaultConnectionStringSection == null) { throw new SimpleLookupsException("More than one connection string was supplied, but there wasn't a default specified.", null); } ValidateConnectionStringExists(defaultConnectionStringSection.ConnectionStringName); AddConnectionInfo(SimpleLookups.DefaultConnectionName, ConfigurationManager.ConnectionStrings[defaultConnectionStringSection.ConnectionStringName].ConnectionString); foreach (IConnectionStringConfigurationElement c in configSection.ConnectionStrings) { ValidateConnectionStringExists(c.ConnectionStringName); AddConnectionInfo(c.ConnectionStringName, ConfigurationManager.ConnectionStrings[c.ConnectionStringName].ConnectionString); } if (!string.IsNullOrEmpty(configSection.IdColumnSuffix)) { IdColumnSuffix = configSection.IdColumnSuffix.Trim(); } if (!string.IsNullOrEmpty(configSection.NameColumnSuffix)) { NameColumnSuffix = configSection.NameColumnSuffix.Trim(); } if (!string.IsNullOrEmpty(configSection.DescriptionColumnSuffix)) { DescriptionColumnSuffix = configSection.DescriptionColumnSuffix.Trim(); } if (!string.IsNullOrEmpty(configSection.CodeColumnSuffix)) { CodeColumnSuffix = configSection.CodeColumnSuffix.Trim(); } if (!string.IsNullOrEmpty(configSection.ActiveColumnName)) { ActiveColumnName = configSection.ActiveColumnName.Trim(); } PrefixColumnsWithTableName = configSection.PrefixColumnsWithTableName; EnableCaching = configSection.EnableCaching; CacheRefreshPeriod = configSection.CacheRefreshPeriod; SimpleLookups.IsInitialized = true; } }
internal SimpleLookupsConfiguration(ISimpleLookupsConfigurationSection configSection) { ConnectionInfos = new List<IConnectionInfo>(); SetDefaults(); if(configSection != null) { var defaultConnectionStringSection = configSection.ConnectionStrings.GetDefault(); if (defaultConnectionStringSection == null) throw new SimpleLookupsException("More than one connection string was supplied, but there wasn't a default specified.", null); ValidateConnectionStringExists(defaultConnectionStringSection.ConnectionStringName); AddConnectionInfo(SimpleLookups.DefaultConnectionName, ConfigurationManager.ConnectionStrings[defaultConnectionStringSection.ConnectionStringName].ConnectionString); foreach (IConnectionStringConfigurationElement c in configSection.ConnectionStrings) { ValidateConnectionStringExists(c.ConnectionStringName); AddConnectionInfo(c.ConnectionStringName, ConfigurationManager.ConnectionStrings[c.ConnectionStringName].ConnectionString); } if (!string.IsNullOrEmpty(configSection.IdColumnSuffix)) IdColumnSuffix = configSection.IdColumnSuffix.Trim(); if (!string.IsNullOrEmpty(configSection.NameColumnSuffix)) NameColumnSuffix = configSection.NameColumnSuffix.Trim(); if (!string.IsNullOrEmpty(configSection.DescriptionColumnSuffix)) DescriptionColumnSuffix = configSection.DescriptionColumnSuffix.Trim(); if (!string.IsNullOrEmpty(configSection.CodeColumnSuffix)) CodeColumnSuffix = configSection.CodeColumnSuffix.Trim(); if (!string.IsNullOrEmpty(configSection.ActiveColumnName)) ActiveColumnName = configSection.ActiveColumnName.Trim(); PrefixColumnsWithTableName = configSection.PrefixColumnsWithTableName; EnableCaching = configSection.EnableCaching; CacheRefreshPeriod = configSection.CacheRefreshPeriod; SimpleLookups.IsInitialized = true; } }