Exemple #1
0
/// <summary>
        /// Gets the factory section instance.
        /// </summary>
        internal static void InitializeFactorySection()
        {
            try
            {
                lockFactorySection.EnterUpgradeableReadLock();
                if (factorySectionAlreadyInitialized)
                {
                    return;
                }

                if (ConfigurationManager.GetSection(AdoFactoriesConfigurationSection.SECTION_NAME) != null)
                {
                    AdoFactoriesConfigurationSection configFileSection = ConfigurationManager.GetSection(AdoFactoriesConfigurationSection.SECTION_NAME) as AdoFactoriesConfigurationSection;
                    if (configFileSection != null)
                    {
                        try
                        {
                            lockFactorySection.EnterWriteLock();
                            factorySection = new Dictionary <string, FactoryConfigurationElement>();
                            foreach (FactoryConfigurationElement elem in configFileSection.Factories)
                            {
                                if (!factorySection.ContainsKey(elem.Name))
                                {
                                    factorySection.Add(elem.Name, elem);
                                }
                            }
                        }
                        finally
                        {
                            lockFactorySection.ExitWriteLock();
                        }
                    }
                }
                try
                {
                    lockFactorySection.EnterWriteLock();
                    if (factorySection == null)
                    {
                        factorySection = new Dictionary <string, FactoryConfigurationElement>();
                        LoadDefaultFactorySettings(factorySection);
                    }
                }
                finally
                {
                    lockFactorySection.ExitWriteLock();
                }
                if (factorySection == null)
                {
                    throw new ArgumentException("There was an error getting the configuration file information. Please check the configuration file.");
                }
            }
            finally
            {
                factorySectionAlreadyInitialized = true;
                lockFactorySection.ExitUpgradeableReadLock();
            }
        }
Exemple #2
0
        private static AdoFactoriesConfigurationSection GetDefaultFactoriesSettings()
        {
            AdoFactoriesConfigurationSection newfactorySection = new AdoFactoriesConfigurationSection();

            newfactorySection.Factories.Add(new FactoryConfigurationElement("Access", "System.Data.OleDb", DatabaseType.Access, true));
            newfactorySection.Factories.Add(new FactoryConfigurationElement("SQLServer", "System.Data.SqlClient", DatabaseType.SQLServer, false));
            //New Changes
            //newfactorySection.Factories.Add(new FactoryConfigurationElement("Oracle", "Oracle.DataAccess.Client", DatabaseType.Oracle, false));
            newfactorySection.Factories.Add(new FactoryConfigurationElement("Oracle", "System.Data.OracleClient", DatabaseType.Oracle, false));
            newfactorySection.Factories.Add(new FactoryConfigurationElement("ODBC", "System.Data.Odbc", DatabaseType.Access, false));
            return(newfactorySection);
        }