Exemplo 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;
 }
Exemplo n.º 2
0
 protected override bool Gt(ValueProxy val)
 {
     return ((IComparable)_value).CompareTo(val.Value) > 0;
 }
Exemplo n.º 3
0
 protected override Integer IDiv(ValueProxy value)
 {
     throw new OperatorMismatchException(Funcs.IDiv, _value, value.Value);
 }
Exemplo n.º 4
0
 protected override ValueProxy Promote(ValueProxy val)
 {
     throw new NotImplementedException();
 }
Exemplo 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);
 }
Exemplo n.º 6
0
 protected override bool Gt(ValueProxy val)
 {
     throw new OperatorMismatchException(Funcs.Gt, _value, val.Value);
 }
Exemplo 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);
                }
            }
Exemplo n.º 8
0
 protected abstract Integer IDiv(ValueProxy val);
Exemplo 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);
     }
 }
Exemplo n.º 10
0
 public ShadowProxy(ValueProxy proxy)
 {
     _value = proxy.Value;
     _valueCode = proxy.GetValueCode();
     _isNumeric = proxy.IsNumeric();
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
     }
 }
Exemplo 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();
 }
Exemplo 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;
 }
Exemplo n.º 16
0
 protected abstract ValueProxy Sub(ValueProxy val);
Exemplo n.º 17
0
 protected abstract ValueProxy Div(ValueProxy val);
Exemplo 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);
                    }
            }
        }
Exemplo n.º 19
0
 protected abstract ValueProxy Mod(ValueProxy val);
Exemplo 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;
                    }
            }
        }
Exemplo n.º 21
0
 protected override bool Eq(ValueProxy val)
 {
     return _value.Equals(val.Value);
 }
Exemplo 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);
                    }
            }
        }
Exemplo n.º 23
0
 protected override ValueProxy Mul(ValueProxy val)
 {
     throw new OperatorMismatchException(Funcs.Mul, _value, val.Value);
 }
Exemplo n.º 24
0
 protected abstract bool Gt(ValueProxy val);
Exemplo 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;
 }
Exemplo 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;
        }
Exemplo 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);
                }
            }
Exemplo n.º 28
0
 protected abstract ValueProxy Promote(ValueProxy val);
Exemplo n.º 29
0
 protected override ValueProxy Mod(ValueProxy value)
 {
     throw new OperatorMismatchException(Funcs.Div, _value, value.Value);
 }
Exemplo 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);
     }
 }