コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        protected override void Reset(ConfigurationElement parentSection)
        {
            EasyDbConfiguration psec = parentSection as EasyDbConfiguration;

            if (psec != null)
            {
                Providers.Reset(psec.Providers);
            }
        }
コード例 #2
0
ファイル: EasyDbHelper.cs プロジェクト: wyerp/EasyDb.NET
        /// <summary>
        /// Initializes EasyDbHelper.
        /// </summary>
        /// <param name="config">the <see cref="LX.EasyDb.Configuration.EasyDbConfiguration"/></param>
        public static void Initialize(EasyDbConfiguration config)
        {
            if (config != null && config.Providers.Count > 0)
            {
                IConnectionFactory masterProvider = null;
                List<IConnectionFactory> slaveProviders = new List<IConnectionFactory>();

                DbProviderElement primaryProviderElement = config.MasterProvider;
                if (null == primaryProviderElement)
                    throw new ConfigurationErrorsException("Master provider is not found.");
                masterProvider = CreateConnectionFactory(primaryProviderElement);
                if (masterProvider == null)
                    throw new ConfigurationErrorsException("Unable to load " + primaryProviderElement.Name);

                // TODO slave mode
                ConnectionFactory = masterProvider;
            }
        }