Esempio n. 1
0
 protected virtual bool TryGt(ValueProxy val, out bool res)
 {
     res = false;
     if (val.GetValueCode() == GetValueCode())
     {
         res = Gt(val);
         return true;
     }
     return false;
 }
Esempio n. 2
0
 protected override bool Gt(ValueProxy val)
 {
     return ((IComparable)_value).CompareTo(val.Value) > 0;
 }
Esempio n. 3
0
 protected override Integer IDiv(ValueProxy value)
 {
     throw new OperatorMismatchException(Funcs.IDiv, _value, value.Value);
 }
Esempio n. 4
0
 protected override ValueProxy Promote(ValueProxy val)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
 protected override bool Eq(ValueProxy val)
 {
     if (val.GetValueCode() != ProxyValueCode)
         throw new OperatorMismatchException(Funcs.Eq, _value, val.Value);
     return _value.Equals(((Proxy)val)._value);
 }
Esempio n. 6
0
 protected override bool Gt(ValueProxy val)
 {
     throw new OperatorMismatchException(Funcs.Gt, _value, val.Value);
 }
Esempio n. 7
0
            protected override ValueProxy Add(ValueProxy value)
            {
                switch (value.GetValueCode())
                {
                    case YearMonthDurationValue.ProxyValueCode:
                        return new Proxy(DateValue.Add(_value, (YearMonthDurationValue)value.Value));
                    case DayTimeDurationValue.ProxyValueCode:
                        return new Proxy(DateValue.Add(_value, (DayTimeDurationValue)value.Value));

                    default:
                        throw new OperatorMismatchException(Funcs.Add, _value, value.Value);
                }
            }
Esempio n. 8
0
 protected abstract Integer IDiv(ValueProxy val);
Esempio n. 9
0
 protected override ValueProxy Mul(ValueProxy val)
 {
     switch (val.GetValueCode())
     {
         case YearMonthDurationValue.ProxyValueCode:
             return new YearMonthDurationValue.Proxy(
                 YearMonthDurationValue.Multiply((YearMonthDurationValue)val.Value, Convert.ToDouble(_value)));
         case DayTimeDurationValue.ProxyValueCode:
             return new DayTimeDurationValue.Proxy(
                 DayTimeDurationValue.Multiply((DayTimeDurationValue)val.Value, Convert.ToDouble(_value)));
         default:
             throw new OperatorMismatchException(Funcs.Mul, _value, val.Value);
     }
 }
Esempio n. 10
0
 public ShadowProxy(ValueProxy proxy)
 {
     _value = proxy.Value;
     _valueCode = proxy.GetValueCode();
     _isNumeric = proxy.IsNumeric();
 }
Esempio n. 11
0
 protected override ValueProxy Div(ValueProxy value)
 {
     if (value.IsNumeric())
         return new Proxy(DayTimeDurationValue.Divide(_value, Convert.ToDouble(value)));
     else if (value.GetValueCode() == DayTimeDurationValue.ProxyValueCode)
         return new DataEngine.CoreServices.Proxy.DecimalProxy(
             DayTimeDurationValue.Divide(_value, (DayTimeDurationValue)value.Value));
     else
         throw new OperatorMismatchException(Funcs.Div, _value, value.Value);
 }
Esempio n. 12
0
 protected override ValueProxy Mul(ValueProxy value)
 {
     if (value.IsNumeric())
         return new Proxy(DayTimeDurationValue.Multiply(_value, Convert.ToDouble(value)));
     throw new OperatorMismatchException(Funcs.Mul, _value, value.Value);
 }
Esempio n. 13
0
 protected override ValueProxy Add(ValueProxy value)
 {
     switch (value.GetValueCode())
     {
         case DayTimeDurationValue.ProxyValueCode:
             return new Proxy(new DayTimeDurationValue(_value.LowPartValue + ((DayTimeDurationValue)value.Value).LowPartValue));
         case DateTimeValue.ProxyValueCode:
             return new DateTimeValue.Proxy(DateTimeValue.Add((DateTimeValue)value.Value, _value));
         case DateValue.ProxyValueCode:
             return new DateValue.Proxy(DateValue.Add((DateValue)value.Value, _value));
         case TimeValue.ProxyValueCode:
             return new TimeValue.Proxy(TimeValue.Add((TimeValue)value.Value, _value));
         default:
             throw new OperatorMismatchException(Funcs.Add, _value, value.Value);
     }
 }
Esempio n. 14
0
 protected override ValueProxy Promote(ValueProxy val)
 {
     if (val.IsNumeric())
         return new ShadowProxy(val);
     if (val.GetValueCode() == DurationValue.ProxyValueCode)
     {
         DurationValue duration = (DurationValue)val.Value;
         return new Proxy(new DayTimeDurationValue(duration.LowPartValue));
     }
     throw new InvalidCastException();
 }
Esempio n. 15
0
 protected override bool TryGt(ValueProxy val, out bool res)
 {
     res = false;
     if (val.GetValueCode() != DayTimeDurationValue.ProxyValueCode)
         return false;
     res = ((IComparable)_value).CompareTo(val.Value) > 0;
     return true;
 }
Esempio n. 16
0
 protected abstract ValueProxy Sub(ValueProxy val);
Esempio n. 17
0
 protected abstract ValueProxy Div(ValueProxy val);
Esempio n. 18
0
        public static bool Equals(ValueProxy val1, ValueProxy val2)
        {
            switch (conv_t[val1.GetValueCode(), val2.GetValueCode()])
            {
                case -1:
                    return val2.Promote(val1).Eq(val2);

                case 0:
                    return val1.Eq(val2);

                case 1:
                    return val1.Eq(val1.Promote(val2));

                default:
                    {
                        if (conv_t[val2.GetValueCode(), val1.GetValueCode()] == 1)
                            return val2.Promote(val1).Eq(val2);
                        throw new OperatorMismatchException(Funcs.Eq, val1, val2);
                    }
            }
        }
Esempio n. 19
0
 protected abstract ValueProxy Mod(ValueProxy val);
Esempio n. 20
0
        public static bool Gt(ValueProxy val1, ValueProxy val2, out bool res)
        {
            res = false;
            switch (conv_t[val1.GetValueCode(), val2.GetValueCode()])
            {
                case -1:
                    return val2.Promote(val1).TryGt(val2, out res);

                case 0:
                    return val1.TryGt(val2, out res);

                case 1:
                    return val1.TryGt(val1.Promote(val2), out res);

                default:
                    {
                        if (conv_t[val2.GetValueCode(), val1.GetValueCode()] == 1)
                            return val2.Promote(val1).TryGt(val2, out res);
                        return false;
                    }
            }
        }
Esempio n. 21
0
 protected override bool Eq(ValueProxy val)
 {
     return _value.Equals(val.Value);
 }
Esempio n. 22
0
        public static Integer op_IntegerDivide(ValueProxy val1, ValueProxy val2)
        {
            switch (conv_t[val1.GetValueCode(), val2.GetValueCode()])
            {
                case -1:
                    return val2.Promote(val1).IDiv(val2);

                case 0:
                    return val1.IDiv(val2);

                case 1:
                    return val1.IDiv(val1.Promote(val2));

                default:
                    {
                        if (conv_t[val2.GetValueCode(), val1.GetValueCode()] == 1)
                            return val2.Promote(val1).IDiv(val2);
                        throw new OperatorMismatchException(Funcs.IDiv, val1, val2);
                    }
            }
        }
Esempio n. 23
0
 protected override ValueProxy Mul(ValueProxy val)
 {
     throw new OperatorMismatchException(Funcs.Mul, _value, val.Value);
 }
Esempio n. 24
0
 protected abstract bool Gt(ValueProxy val);
Esempio n. 25
0
 protected override bool Gt(ValueProxy val)
 {
     if (val.GetValueCode() != ProxyValueCode)
         throw new OperatorMismatchException(Funcs.Gt, _value, val.Value);
     return ((IComparable)_value).CompareTo(((Proxy)val)._value) > 0;
 }
Esempio n. 26
0
        public static ValueProxy Min(ValueProxy val1, ValueProxy val2)
        {
            switch (conv_t[val1.GetValueCode(), val2.GetValueCode()])
            {
                case -1:
                    val1 = val2.Promote(val1);
                    break;

                case 0:
                    break;

                case 1:
                    val2 = val1.Promote(val2);
                    break;

                default:
                    {
                        if (conv_t[val2.GetValueCode(), val1.GetValueCode()] == 1)
                            val1 = val2.Promote(val1);
                        else
                            throw new OperatorMismatchException(Funcs.Gt, val1, val2);
                    }
                    break;
            }
            if (val2.IsNaN() || val1.Gt(val2))
                return val2;
            return val1;
        }
Esempio n. 27
0
            protected override ValueProxy Sub(ValueProxy value)
            {
                switch (value.GetValueCode())
                {
                    case TimeValue.ProxyValueCode:
                        return new DayTimeDurationValue.Proxy(TimeValue.Sub(_value, (TimeValue)value.Value));
                    case DayTimeDurationValue.ProxyValueCode:
                        return new Proxy(TimeValue.Add(_value, -(DayTimeDurationValue)value.Value));

                    default:
                        throw new OperatorMismatchException(Funcs.Sub, _value, value.Value);
                }
            }
Esempio n. 28
0
 protected abstract ValueProxy Promote(ValueProxy val);
Esempio n. 29
0
 protected override ValueProxy Mod(ValueProxy value)
 {
     throw new OperatorMismatchException(Funcs.Div, _value, value.Value);
 }
Esempio n. 30
0
 protected override ValueProxy Sub(ValueProxy value)
 {
     switch (value.GetValueCode())
     {
         case YearMonthDurationValue.ProxyValueCode:
             return new Proxy(new YearMonthDurationValue(_value.HighPartValue - ((YearMonthDurationValue)value.Value).HighPartValue));
         default:
             throw new OperatorMismatchException(Funcs.Sub, _value, value.Value);
     }
 }