示例#1
0
        public Context(bool hasSqlAccess)
        {
            SqlConnectorManager sqlCon = new SqlConnectorManager();

            if (hasSqlAccess)//else if web we should give the URL to the data access
            {
                sqlCon.InitializeConnection(@"C:\PosLite\PosLite.s3db");
            }

            BusinessEntities = new Dictionary <Type, IBusinessBase>();
            DataEntities     = new Dictionary <Type, IDataBase>();
            var typeOfDataBase     = typeof(IDataBase);
            var typeOfBusinessBase = typeof(IBusinessBase);

            //Loads all Data Entities
            foreach (var type in ExistingIDataBase)
            {
                var entity = hasSqlAccess?(IDataBase)Activator.CreateInstance(type) : (IDataBase)Activator.CreateInstance(type, sqlCon);

                //get interface that is not a base (isgeneric refers to iblentity<T>)
                var first = type.GetInterfaces().First(x => x.IsGenericType == false && !(x.Equals(typeOfDataBase)));
                DataEntities.Add(first, entity);
            }

            foreach (var type in ExistingIBusinessBase)
            {
                //get interface that is not a base
                var first       = type.GetInterfaces().First(x => x.IsGenericType == false && !(x.Equals(typeOfBusinessBase)));
                var transaction = (IBusinessBase)Activator.CreateInstance(type);
                BusinessEntities.Add(first, transaction);
            }
        }
示例#2
0
        public Context(string dbLocation)
        {
            SqlConnectorManager sqlCon = null;

            sqlCon = new SqlConnectorManager();
            sqlCon.InitializeConnection(dbLocation);

            DbAccess = new Dictionary <Type, IDgvDbAccess>
            {
                { typeof(IPrinterBillsHistoryDE), new PrinterBillsHistoryDE(sqlCon) },
                { typeof(IFamiliesDE), new FamiliesDE(sqlCon) },
                { typeof(IMenuProductsDE), new MenuProductsDE(sqlCon) },
                { typeof(IOrderItemsDE), new OrderItemsDE(sqlCon) },
                { typeof(IOrderItemsHistoryDE), new OrderItemsHistoryDE(sqlCon) },
                { typeof(IOrdersDE), new OrdersDE(sqlCon) },
                { typeof(IOrdersHistoryDE), new OrdersHistoryDE(sqlCon) },
                { typeof(IProductsDE), new ProductsDE(sqlCon) },
                { typeof(ITablesDE), new TablesDE(sqlCon) },
                { typeof(IUsersDE), new UsersDE(sqlCon) },
                { typeof(ILanguagesDE), new LanguagesDE(sqlCon) },
                { typeof(ITranslationsDE), new TranslationsDE(sqlCon) },
                { typeof(IMenusDE), new MenusDE(sqlCon) }
            };
        }