コード例 #1
0
        /// <summary>
        /// Given a section name and provider name locate the necessary
        /// <see cref="IAdoValueReader" /> in the configuration file.
        /// </summary>
        /// <param name="providerName">
        /// The name that uniquely identifies an ADO.NET provider.
        /// </param>
        /// <returns>
        /// An <see cref="IAdoValueReader" />.
        /// </returns>
        public static IAdoValueReader Create(String providerName)
        {
            // locate any mappings for the specified provider
            ProviderNameTypeMapping mapping = CommonAdoProviderSettings.Get()
                                              .ValueReaders.FindByProviderName(providerName);

            IAdoValueReader valueReader;

            if (mapping != null)
            {
                valueReader = TypeUtilities.CreateInstance <IAdoValueReader>(mapping.Type);
            }
            else
            {
                // no value reader mapping found in config
                // return the default value reader
                valueReader = new DefaultAdoValueReader();
            }

            return(valueReader);
        }
コード例 #2
0
        /// <summary>
        /// Given a provider name either locate the necessary <see cref="IAdoResourceProvider" />
        /// in the configuration file or return the default (<see cref="DefaultAdoResourceProvider" />).
        /// </summary>
        /// <param name="connectionStringSettings">
        /// The name that uniquely identifies an ADO.NET provider.
        /// </param>
        /// <returns>
        /// An <see cref="IAdoResourceProvider" />.
        /// </returns>
        public static IAdoResourceProvider Create(ConnectionStringSettings connectionStringSettings)
        {
            // locate any mappings for the specified provider
            ProviderNameTypeMapping mapping = CommonAdoProviderSettings.Get()
                                              .ResourceProviders.FindByProviderName(connectionStringSettings.ProviderName);

            IAdoResourceProvider resourceProvider = null;

            if (mapping != null)
            {
                resourceProvider = TypeUtilities.CreateInstance <IAdoResourceProvider>(mapping.Type);
            }

            if (resourceProvider == null)
            {
                // no resource provider mapping found in config
                // return the default resource provider
                resourceProvider = new DefaultAdoResourceProvider();
            }

            resourceProvider.Initialise(connectionStringSettings);

            return(resourceProvider);
        }