public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { DatabaseConfigurationView view = new DatabaseConfigurationView(configurationSource); ConnectionStringSettings connectionStringSettings = view.GetConnectionStringSettings(name); DbProviderMapping providerMapping = view.GetProviderMapping(name, connectionStringSettings.ProviderName); return this.GetAssembler(providerMapping.DatabaseType, name, reflectionCache).Assemble(name, connectionStringSettings, configurationSource); }
/// <summary> /// <para>Gets the <see cref="Type"/> of <see cref="Database"/> to create based on the name of the <see cref="InstanceData"/>.</para> /// </summary> /// <param name="instanceName"> /// <para>The name of the <see cref="InstanceData"/> to get the <see cref="Type"/>.</para> /// </param> /// <returns> /// <para>The <see cref="Type"/> of the <see cref="Database"/> to create.</para> /// </returns> protected override Type GetConfigurationType(string instanceName) { DatabaseConfigurationView view = (DatabaseConfigurationView)CreateConfigurationView(); DatabaseProviderData databaseTypeData = view.GetDatabaseProviderData(instanceName); return(GetType(databaseTypeData.TypeName)); }
/// <summary> /// Returns an new instance of the type the receiver knows how to build. /// </summary> /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param> /// <param name="name">The name of the instance to build, or null.</param> /// <param name="configurationSource">The source for configuration objects.</param> /// <param name="reflectionCache">The cache to use retrieving reflection information.</param> /// <returns>The new instance.</returns> public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { DatabaseConfigurationView databaseConfigurationView = new DatabaseConfigurationView(configurationSource); ConnectionStringSettings connectionStringSettings = databaseConfigurationView.GetConnectionStringSettings(name); DbSchemaProviderConfigurationView dbSchemaProviderConfigurationView = new DbSchemaProviderConfigurationView(configurationSource); DbSchemaProviderMapping mapping = dbSchemaProviderConfigurationView.GetProviderMapping(connectionStringSettings.ProviderName); return Activator.CreateInstance(mapping.DbSchemaProviderType); }
public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { DatabaseConfigurationView configurationView = new DatabaseConfigurationView(configurationSource); ConnectionStringSettings connectionStringSettings = configurationView.GetConnectionStringSettings(name); DbProviderMapping mapping = configurationView.GetProviderMapping(name, connectionStringSettings.ProviderName); IDatabaseAssembler assembler = GetAssembler(mapping.DatabaseType, name, reflectionCache); Database database = assembler.Assemble(name, connectionStringSettings, configurationSource); return(database); }
/// <summary> /// This method supports the Enterprise Library infrastructure and is not intended to be used directly from your code. /// Returns a new instance of a concrete <see cref="Database"/>, described by the <see cref="ConnectionStringSettings"/> /// found in the <paramref name="configurationSource"/> under the name <paramref name="name"/>, plus any additional /// configuration information that might describe the the concrete <b>Database</b>. /// </summary> /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param> /// <param name="name">The name of the instance to build, or <see langword="null"/> (<b>Nothing</b> in Visual Basic).</param> /// <param name="configurationSource">The source for configuration objects.</param> /// <param name="reflectionCache">The cache to use retrieving reflection information.</param> /// <returns>A new instance of the appropriate subtype of <typeparamref name="Tobject"/>.</returns> /// <exception cref="ConfigurationErrorsException">when the configuration is invalid or <paramref name="name"/> cannot be found.</exception> public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { DatabaseConfigurationView configurationView = new DatabaseConfigurationView(configurationSource); ConnectionStringSettings connectionStringSettings = configurationView.GetConnectionStringSettings(name); DbProviderMapping mapping = configurationView.GetProviderMapping(name, connectionStringSettings.ProviderName); IDatabaseAssembler assembler = GetAssembler(mapping.DatabaseType, name, reflectionCache); Database database = assembler.Assemble(name, connectionStringSettings, configurationSource); return database; }
/// <summary> /// <para>Gets the default database instance type.</para> /// </summary> /// <returns> /// <para>The default database instance type.</para> /// </returns> protected override string GetDefaultInstanceName() { DatabaseConfigurationView view = (DatabaseConfigurationView)CreateConfigurationView(); return(view.GetDefaultInstanceName()); }
/// <summary> /// <para>Initializes a new instance of the <see cref="Database"/> class with the specified <see cref="DatabaseProviderData"/> and <see cref="ConfigurationContext"/>.</para> /// </summary> /// <param name="configurationView">A <see cref="ConfigurationView"/> that should be of type <see cref="DatabaseConfigurationView"/>.</param> public override void Initialize(ConfigurationView configurationView) { ArgumentValidation.CheckForNullReference(configurationView, "configurationView"); ArgumentValidation.CheckExpectedType(configurationView, typeof(DatabaseConfigurationView)); this.databaseConfigurationView = (DatabaseConfigurationView)configurationView; instrumentation = new DataInstrumentationFacade(); }