public SqlDataProviderConfiguration(string providerName) { _configurationFilePath = GetConfigurationFilePath(providerName); _configuration = new C1Configuration(_configurationFilePath); Section = _configuration.GetSection(SqlDataProviderConfigurationSection.SectionName) as SqlDataProviderConfigurationSection; if (Section == null) { Section = new SqlDataProviderConfigurationSection(); _configuration.Sections.Add(SqlDataProviderConfigurationSection.SectionName, Section); } }
public SqlDataProviderConfiguration(string providerName) { _configurationFilePath = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.ConfigurationDirectory), string.Format("{0}.config", providerName)); _configuration = new C1Configuration(_configurationFilePath); Section = _configuration.GetSection(SqlDataProviderConfigurationSection.SectionName) as SqlDataProviderConfigurationSection; if (Section == null) { Section = new SqlDataProviderConfigurationSection(); _configuration.Sections.Add(SqlDataProviderConfigurationSection.SectionName, Section); } }
internal IDataProvider Assemble(IBuilderContext context, DataProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache, string configurationFolderPath) { var data = (XmlDataProviderData)objectConfiguration; var configuration = new C1Configuration(Path.Combine(configurationFolderPath, string.Format("{0}.config", data.Name))); var section = configuration.GetSection(XmlDataProviderConfigurationSection.SectionName) as XmlDataProviderConfigurationSection; if (section == null) { section = new XmlDataProviderConfigurationSection(); configuration.Sections.Add(XmlDataProviderConfigurationSection.SectionName, section); configuration.Save(); } var dataTypeConfigurationElements = section.Interfaces.Cast <XmlProviderInterfaceConfigurationElement>().ToList(); return(new XmlDataProvider(PathUtil.Resolve(data.StoreDirectory), dataTypeConfigurationElements)); }
public IDataProvider Assemble(IBuilderContext context, DataProviderData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { var sqlDataProviderData = (SqlDataProviderData)objectConfiguration; string configFilePath = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.ConfigurationDirectory), string.Format("{0}.config", sqlDataProviderData.Name)); var configuration = new C1Configuration(configFilePath); var section = configuration.GetSection(SqlDataProviderConfigurationSection.SectionName) as SqlDataProviderConfigurationSection; if (section == null) { section = new SqlDataProviderConfigurationSection(); configuration.Sections.Add(SqlDataProviderConfigurationSection.SectionName, section); configuration.Save(); } var interfaceConfigurationElements = new List <InterfaceConfigurationElement>(); foreach (InterfaceConfigurationElement table in section.Interfaces) { interfaceConfigurationElements.Add(table); } var sqlLoggingContext = new SqlLoggingContext { Enabled = sqlDataProviderData.SqlQueryLoggingEnabled, IncludeStack = sqlDataProviderData.SqlQueryLoggingIncludeStack, TypesToIgnore = new List <Type>(), TablesToIgnore = new List <string>() }; if (sqlDataProviderData.SqlQueryLoggingEnabled) { foreach (LoggingIgnoreInterfacesConfigurationElement element in sqlDataProviderData.LoggingIgnoreInterfaces) { Type interfaceType = TypeManager.TryGetType(element.InterfaceType); if (interfaceType != null) { sqlLoggingContext.TypesToIgnore.Add(interfaceType); InterfaceConfigurationElement interfaceElement = interfaceConfigurationElements.SingleOrDefault(f => f.DataTypeId == interfaceType.GetImmutableTypeId()); if (interfaceElement == null) { continue; } foreach (StoreConfigurationElement store in interfaceElement.ConfigurationStores) { sqlLoggingContext.TablesToIgnore.Add(store.TableName); } } } } string connectionString = sqlDataProviderData.ConnectionString; if (string.IsNullOrEmpty(connectionString)) { string connectionStringName = sqlDataProviderData.ConnectionStringName; if (string.IsNullOrEmpty(connectionStringName)) { throw new ConfigurationErrorsException("SqlDataProvider requires one of the following properties to be specified: 'connectionString', 'connectionStringName'"); } var connStringConfigNode = System.Web.Configuration.WebConfigurationManager.ConnectionStrings[connectionStringName]; Verify.IsNotNull(connStringConfigNode, "Failed to find an SQL connection string by name '{0}'", connectionStringName); connectionString = connStringConfigNode.ConnectionString; } return(new SqlDataProvider(connectionString, interfaceConfigurationElements, sqlLoggingContext)); }