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