Пример #1
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;
        }
Пример #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);
        }