protected virtual bool TryGt(ValueProxy val, out bool res) { res = false; if (val.GetValueCode() == GetValueCode()) { res = Gt(val); return true; } return false; }
protected override bool Gt(ValueProxy val) { return ((IComparable)_value).CompareTo(val.Value) > 0; }
protected override Integer IDiv(ValueProxy value) { throw new OperatorMismatchException(Funcs.IDiv, _value, value.Value); }
protected override ValueProxy Promote(ValueProxy val) { throw new NotImplementedException(); }
protected override bool Eq(ValueProxy val) { if (val.GetValueCode() != ProxyValueCode) throw new OperatorMismatchException(Funcs.Eq, _value, val.Value); return _value.Equals(((Proxy)val)._value); }
protected override bool Gt(ValueProxy val) { throw new OperatorMismatchException(Funcs.Gt, _value, val.Value); }
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); } }
protected abstract Integer IDiv(ValueProxy val);
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); } }
public ShadowProxy(ValueProxy proxy) { _value = proxy.Value; _valueCode = proxy.GetValueCode(); _isNumeric = proxy.IsNumeric(); }
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); }
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); }
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); } }
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(); }
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; }
protected abstract ValueProxy Sub(ValueProxy val);
protected abstract ValueProxy Div(ValueProxy val);
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); } } }
protected abstract ValueProxy Mod(ValueProxy val);
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; } } }
protected override bool Eq(ValueProxy val) { return _value.Equals(val.Value); }
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); } } }
protected override ValueProxy Mul(ValueProxy val) { throw new OperatorMismatchException(Funcs.Mul, _value, val.Value); }
protected abstract bool Gt(ValueProxy val);
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; }
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; }
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); } }
protected abstract ValueProxy Promote(ValueProxy val);
protected override ValueProxy Mod(ValueProxy value) { throw new OperatorMismatchException(Funcs.Div, _value, value.Value); }
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); } }