Пример #1
0
        /// <summary>
        /// Method for invoking a specified Database service object.  Reads service settings
        /// from the ConnectionSettings.config file.
        /// </summary>
        /// <example>
        /// <code>
        /// Database dbSvc = DatabaseFactory.CreateDatabase("SQL_Customers");
        /// </code>
        /// </example>
        /// <param name="name">configuration key for database service</param>
        /// <returns>Database</returns>
        /// <exception cref="System.Configuration.ConfigurationException">
        /// <para><paramref name="instanceName"/> is not defined in configuration.</para>
        /// <para>- or -</para>
        /// <para>An error exists in the configuration.</para>
        /// <para>- or -</para>
        /// <para>An error occured while reading the configuration.</para>
        /// </exception>
        /// <exception cref="System.Reflection.TargetInvocationException">
        /// <para>The constructor being called throws an exception.</para>
        /// </exception>
        public static Database CreateDatabase(string name)
        {
            try
            {
                DatabaseProviderFactory factory = new DatabaseProviderFactory(ConfigurationSourceFactory.Create());
                return(factory.Create(name));
            }
            catch (ConfigurationErrorsException configurationException)
            {
                TryLogConfigurationError(configurationException, name);

                throw;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LocatorNameTypeFactoryBase{T}"/> class with the default configuration source
 /// and a locator.
 /// </summary>
 protected LocatorNameTypeFactoryBase()
     : this(ConfigurationSourceFactory.Create())
 {
 }