Ejemplo n.º 1
0
        private void onTypeChanged(eFLim Old, eFLim New)
        {
            EventHandler <EA_valueChange <eFLim> > handler = event_changedType;

            if (handler != null)
            {
                handler(this, new EA_valueChange <eFLim>(Old, New));
            }
        }
Ejemplo n.º 2
0
        public static Func <DateTime, DateTime> generateStatic
            (eFLim direction, DateTime minLimit, DateTime maxLimit)
        {
            BlockExpression block;

            ConstantExpression  pMin    = Expression.Constant(minLimit);
            ConstantExpression  pMax    = Expression.Constant(maxLimit);
            ParameterExpression pDate   = Expression.Parameter(typeof(DateTime));
            ParameterExpression pResult = Expression.Parameter(typeof(DateTime));
            ParameterExpression pTemp   = Expression.Parameter(typeof(DateTime));

            switch (direction)
            {
            case eFLim.Fixed:
                block = Expression.Block(
                    Expression.Assign(pResult, pMin)
                    );
                break;

            case eFLim.Left:
                block = Expression.Block(
                    Expression.IfThenElse(
                        Expression.LessThanOrEqual(pDate, pMax),
                        Expression.Assign(pResult, pDate),
                        Expression.Assign(pResult, pMax))
                    );
                break;

            case eFLim.Right:
                block = Expression.Block(
                    Expression.IfThenElse(
                        Expression.GreaterThanOrEqual(pDate, pMin),
                        Expression.Assign(pResult, pDate),
                        Expression.Assign(pResult, pMin))
                    );
                break;

            default:
                throw new Exception("Неверное значение параметра eFLim метода generateDynamicDir");
            }

            BlockExpression resBlock = Expression.Block(
                typeof(DateTime),
                new[] { pResult, pTemp },
                block,
                pResult
                );

            return(Expression.Lambda <Func <DateTime, DateTime> >(resBlock, pDate).Compile());
        }
Ejemplo n.º 3
0
        public static Func <DateTime, DateTime, double> generateLimitRange(eFLim direction)
        {
            ParameterExpression pMin    = Expression.Parameter(typeof(DateTime));
            ParameterExpression pMax    = Expression.Parameter(typeof(DateTime));
            ParameterExpression pDouble = Expression.Parameter(typeof(double));
            ConstantExpression  cDNull  = Expression.Constant((double)0, typeof(double));
            ConstantExpression  cDUnlim = Expression.Constant((double)-1, typeof(double));

            Func <DateTime, DateTime, double> fncRange = (min, max) =>
            {
                double result = max.Subtract(min).Days;
                return((result < 0) ? 0 : result);
            };
            Expression <Func <DateTime, DateTime, double> > lmbRange = (min, max) => fncRange(min, max);

            BlockExpression block = Expression.Block(typeof(double), cDNull);

            switch (direction)
            {
            case eFLim.Fixed:
                block =
                    Expression.Block(
                        typeof(double),
                        new[] { pDouble },
                        Expression.Assign(pDouble, cDNull),
                        pDouble
                        );
                break;

            case eFLim.Right:
            case eFLim.Left:
                block =
                    Expression.Block(
                        typeof(double),
                        new[] { pDouble },
                        Expression.Assign(pDouble, cDUnlim),
                        pDouble
                        );
                break;
            }

            return(Expression.Lambda <Func <DateTime, DateTime, double> >(block, pMin, pMax).Compile());
        }
Ejemplo n.º 4
0
 public limit(eFLim type, DateTime date)
 {
     this.type = type;
     this.date = date;
 }
Ejemplo n.º 5
0
 public void setTypeLimit(eFLim type)
 {
     this.type = type;
 }
Ejemplo n.º 6
0
 public limit(eFLim type, DateTime date)
 {
     this.type = type;
     this.date = date;
 }
Ejemplo n.º 7
0
 private void onTypeChanged(eFLim Old, eFLim New)
 {
     EventHandler<EA_valueChange<eFLim>> handler = event_changedType;
     if (handler != null) handler(this, new EA_valueChange<eFLim>(Old, New));
 }
Ejemplo n.º 8
0
 public void setTypeLimit(eFLim  type)
 {
     this.type = type;
 }
Ejemplo n.º 9
0
        public static Func<DateTime, DateTime> generateStatic(eFLim direction, DateTime minLimit, DateTime maxLimit)
        {
            BlockExpression block;

            ConstantExpression pMin = Expression.Constant(minLimit);
            ConstantExpression pMax = Expression.Constant(maxLimit);
            ParameterExpression pDate = Expression.Parameter(typeof(DateTime));
            ParameterExpression pResult = Expression.Parameter(typeof(DateTime));
            ParameterExpression pTemp = Expression.Parameter(typeof(DateTime));

            switch (direction)
            {
                case eFLim.Fixed:
                    block = Expression.Block(
                        Expression.Assign(pResult, pMin)
                        );
                    break;

                case eFLim.Left:
                    block = Expression.Block(
                        Expression.IfThenElse(
                            Expression.LessThanOrEqual(pDate, pMax),
                            Expression.Assign(pResult, pDate),
                            Expression.Assign(pResult, pMax))
                        );
                    break;

                case eFLim.Right:
                    block = Expression.Block(
                        Expression.IfThenElse(
                            Expression.GreaterThanOrEqual(pDate, pMin),
                            Expression.Assign(pResult, pDate),
                            Expression.Assign(pResult, pMin))
                        );
                    break;

                default:
                    throw new Exception("Неверное значение параметра eFLim метода generateDynamicDir");
            }

            BlockExpression resBlock = Expression.Block(
            typeof(DateTime),
            new[] { pResult, pTemp },
            block,
            pResult
            );

            return Expression.Lambda<Func<DateTime, DateTime>>(resBlock, pDate).Compile();
        }
Ejemplo n.º 10
0
        public static Func<DateTime, DateTime, double> generateLimitRange(eFLim direction)
        {
            ParameterExpression pMin = Expression.Parameter(typeof(DateTime));
            ParameterExpression pMax = Expression.Parameter(typeof(DateTime));
            ParameterExpression pDouble = Expression.Parameter(typeof(double));
            ConstantExpression cDNull = Expression.Constant((double)0, typeof(double));
            ConstantExpression cDUnlim = Expression.Constant((double)-1, typeof(double));

            Func<DateTime, DateTime, double> fncRange = (min, max) =>
            {
                double result = max.Subtract(min).Days;
                return (result < 0) ? 0 : result;
            };
            Expression<Func<DateTime, DateTime, double>> lmbRange = (min, max) => fncRange(min, max);

            BlockExpression block = Expression.Block(typeof(double), cDNull);

            switch (direction)
            {
                case eFLim.Fixed:
                    block =
                        Expression.Block(
                            typeof(double),
                            new[] { pDouble },
                            Expression.Assign(pDouble, cDNull),
                            pDouble
                            );
                    break;

                case eFLim.Right:
                case eFLim.Left:
                    block =
                        Expression.Block(
                            typeof(double),
                            new[] { pDouble },
                            Expression.Assign(pDouble, cDUnlim),
                            pDouble
                            );
                    break;
            }

            return Expression.Lambda<Func<DateTime, DateTime, double>>(block, pMin, pMax).Compile();
        }