Exemple #1
0
        /// <summary>
        /// Get special Instance of IDataProvider
        /// </summary>
        /// <param name="dbConfiguration"></param>
        /// <returns></returns>
        public static IDataProvider GetInstance(HKHConnectionStringElement dbConfiguration)
        {
            IDataProvider dataProvider = null;

            if (!dataProviders.TryGetValue(dbConfiguration.Name, out dataProvider))
            {
                lock (typeof(DataBaseObjectBuilderFactory))
                {
                    if (!dataProviders.TryGetValue(dbConfiguration.Name, out dataProvider))
                    {
                        dataProvider = new DataProvider(DataBaseObjectBuilderFactory.GetDataBaseObjectBuilder(dbConfiguration));
                        dataProviders.TryAdd(dbConfiguration.Name, dataProvider);
                    }
                }
            }

            return(dataProvider);
        }
 public TransactionController(HKHConnectionStringElement dbConfiguration)
     : this(DataBaseObjectBuilderFactory.GetDataBaseObjectBuilder(dbConfiguration))
 {
 }
Exemple #3
0
        /// <summary>
        /// Get special Instance of IDataProvider
        /// </summary>
        /// <param name="builderType">the type of IDataBaseObjectBuilder</param>
        /// <param name="connectionString"></param>
        /// <param name="inCache">add this DataProvider instance into cache with ConnectionString as key if true</param>
        /// <returns></returns>
        public static IDataProvider GetInstance(Type builderType, string connectionString, bool inCache)
        {
            IDataProvider dataProvider = dataProviders.ContainsKey(connectionString) ? dataProviders[connectionString] : new DataProvider(DataBaseObjectBuilderFactory.GetDataBaseObjectBuilder(builderType, connectionString));

            if (inCache)
            {
                dataProviders.TryAdd(connectionString, dataProvider);
            }
            return(dataProvider);
        }