Esempio n. 1
0
        private void AddSelect(System.Type table, PropertyInfo colonne, Agregat agregat)
        {
            try
            {
                string tableName   = DataBase.SGBD.TableName(table);
                string colonneName = tableName + "." + DataBase.SGBD.ColonnName(colonne);
                switch (agregat)
                {
                case Agregat.AVG:
                    colonneName = "AVG(" + colonneName + ")";
                    break;

                case Agregat.SUM:
                    colonneName = "SUM(" + colonneName + ")";
                    break;

                case Agregat.MIN:
                    colonneName = "MIN(" + colonneName + ")";
                    break;

                case Agregat.MAX:
                    colonneName = "MAX(" + colonneName + ")";
                    break;

                case Agregat.COUNT:
                    colonneName = "COUNT(" + colonneName + ")";
                    break;
                }
                this.colonne += (this.colonne == "" ? "" + colonneName : ", " + colonneName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        public override (MilkProduct, List <MilkProduct>) ProduceProducts(MilkProduct ingredients)
        {
            if (ingredients == null)
            {
                throw new ArgumentNullException("Нет инградиентов");
            }
            var(mainProduct, sideProducts) = Agregat.Transform(ingredients);

            return(mainProduct, sideProducts);
        }
Esempio n. 3
0
 private void AddSelect(Expression expression)
 {
     try
     {
         System.Type[] arguments = this.GetType().GetGenericArguments();
         if (arguments.Length > 0)
         {
             System.Type table = arguments[0];
             if (expression is MemberExpression)
             {
                 MemberExpression operand      = expression as MemberExpression;
                 string           propertyName = operand.Member.Name;
                 var exp = operand.Expression;
                 if (exp is MemberExpression)
                 {
                     MemberExpression foreing = exp as MemberExpression;
                     table = foreing.Type;
                 }
                 PropertyInfo colonne = table.GetProperty(propertyName);
                 AddSelect(table, colonne, Agregat.NOTHING);
             }
             else if (expression is MethodCallExpression)
             {
                 MethodCallExpression operand = expression as MethodCallExpression;
                 string  methodeName          = operand.Method.Name;
                 Agregat agregat      = GetAgregat(methodeName);
                 var     exp          = operand.Arguments[0];
                 string  propertyName = exp.Type.Name;
                 if (exp is UnaryExpression)
                 {
                     UnaryExpression  lbex = exp as UnaryExpression;
                     MemberExpression ope  = lbex.Operand as MemberExpression;
                     exp          = ope.Expression;
                     propertyName = ope.Member.Name;
                 }
                 if (exp is MemberExpression)
                 {
                     MemberExpression foreing = exp as MemberExpression;
                     table = foreing.Type;
                 }
                 PropertyInfo colonne = table.GetProperty(propertyName);
                 AddSelect(table, colonne, agregat);
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 4
0
 public Factory(Agregat agregat)
 {
     Agregat = agregat;
 }
Esempio n. 5
0
 public CreamFactory(Agregat agregat) : base(agregat)
 {
 }
 public CheeseFactory(Agregat agregat) : base(agregat)
 {
 }
 public ButterFactory(Agregat agregat) : base(agregat)
 {
 }