protected override object CoreEvaluateExpression(ITemplatingContext templatingContext) { DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy; object leftObj = null, rightObj = null; Type leftType, rightType; Func<object> onDemandRightExpressionEvaluator; Type[] numericTypes = new Type[] { typeof(Byte), typeof(Int16), typeof(Int32), typeof(Int64), typeof(SByte), typeof(UInt16), typeof(UInt32), typeof(UInt64), typeof(Single), typeof(Double), typeof(Decimal), typeof(Byte?), typeof(Int16?), typeof(Int32?), typeof(Int64?), typeof(SByte?), typeof(UInt16?), typeof(UInt32?), typeof(UInt64?), typeof(Single?), typeof(Double?), typeof(Decimal?) }; if ((object)templatingContext == null) throw new ArgumentNullException(nameof(templatingContext)); // *** THIS MUST USE THIS OVERLOAD OR CODE WILL FAIL *** dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy(false); if ((object)this.LeftExpression != null) leftObj = this.LeftExpression.EvaluateExpression(templatingContext); onDemandRightExpressionEvaluator = () => { if ((object)this.RightExpression != null) return this.RightExpression.EvaluateExpression(templatingContext); else return null; }; if ((object)leftObj == null) return null; leftType = leftObj.GetType(); switch (this.BinaryOperator) { case BinaryOperator.Eq: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs == rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs == rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs == rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs == rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs == rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs == rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs == rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs == rhs; } } else if (typeof(IComparable).IsAssignableFrom(leftType) && typeof(IComparable).IsAssignableFrom(rightType) && rightType.IsAssignableFrom(leftType) && leftType.IsAssignableFrom(rightType)) { IComparable lhs, rhs; int crv; lhs = leftObj.ChangeType<IComparable>(); rhs = rightObj.ChangeType<IComparable>(); if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))"); return crv == 0; } break; } case BinaryOperator.Ne: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs != rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs != rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs != rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs != rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs != rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs != rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs != rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs != rhs; } } else if (typeof(IComparable).IsAssignableFrom(leftType) && typeof(IComparable).IsAssignableFrom(rightType) && rightType.IsAssignableFrom(leftType) && leftType.IsAssignableFrom(rightType)) { IComparable lhs, rhs; int crv; lhs = leftObj.ChangeType<IComparable>(); rhs = rightObj.ChangeType<IComparable>(); if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))"); return crv != 0; } break; } case BinaryOperator.Lt: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs < rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs < rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs < rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs < rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs < rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs < rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs < rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs < rhs; } } else if (typeof(IComparable).IsAssignableFrom(leftType) && typeof(IComparable).IsAssignableFrom(rightType) && rightType.IsAssignableFrom(leftType) && leftType.IsAssignableFrom(rightType)) { IComparable lhs, rhs; int crv; lhs = leftObj.ChangeType<IComparable>(); rhs = rightObj.ChangeType<IComparable>(); if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))"); return crv < 0; } break; } case BinaryOperator.Le: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs <= rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs <= rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs <= rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs <= rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs <= rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs <= rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs <= rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs <= rhs; } } else if (typeof(IComparable).IsAssignableFrom(leftType) && typeof(IComparable).IsAssignableFrom(rightType) && rightType.IsAssignableFrom(leftType) && leftType.IsAssignableFrom(rightType)) { IComparable lhs, rhs; int crv; lhs = leftObj.ChangeType<IComparable>(); rhs = rightObj.ChangeType<IComparable>(); if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))"); return crv <= 0; } break; } case BinaryOperator.Gt: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs > rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs > rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs > rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs > rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs > rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs > rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs > rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs > rhs; } } else if (typeof(IComparable).IsAssignableFrom(leftType) && typeof(IComparable).IsAssignableFrom(rightType) && rightType.IsAssignableFrom(leftType) && leftType.IsAssignableFrom(rightType)) { IComparable lhs, rhs; int crv; lhs = leftObj.ChangeType<IComparable>(); rhs = rightObj.ChangeType<IComparable>(); if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))"); return crv > 0; } break; } case BinaryOperator.Ge: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs >= rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs >= rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs >= rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs >= rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs >= rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs >= rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs >= rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs >= rhs; } } else if (typeof(IComparable).IsAssignableFrom(leftType) && typeof(IComparable).IsAssignableFrom(rightType) && rightType.IsAssignableFrom(leftType) && leftType.IsAssignableFrom(rightType)) { IComparable lhs, rhs; int crv; lhs = leftObj.ChangeType<IComparable>(); rhs = rightObj.ChangeType<IComparable>(); if ((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. |((crv = lhs.CompareTo(rightObj)) != (rhs.CompareTo(leftObj) * -1))"); return crv >= 0; } break; } case BinaryOperator.Add: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs + rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs + rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs + rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs + rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs + rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs + rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs + rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs + rhs; } } break; } case BinaryOperator.Sub: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs - rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs - rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs - rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs - rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs - rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs - rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs - rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs - rhs; } } break; } case BinaryOperator.Mul: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs * rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs * rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs * rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs * rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs * rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs * rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs * rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs * rhs; } } break; } case BinaryOperator.Div: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs / rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs / rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs / rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs / rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs / rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs / rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs / rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs / rhs; } } break; } case BinaryOperator.Mod: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(Decimal) || leftType == typeof(Decimal?) || rightType == typeof(Decimal) || rightType == typeof(Decimal?)) { if (leftType != typeof(Single) && leftType != typeof(Single?) && rightType != typeof(Single) && rightType != typeof(Single?) && leftType != typeof(Double) && leftType != typeof(Double?) && rightType != typeof(Double) && rightType != typeof(Double?)) { Decimal lhs, rhs; lhs = leftObj.ChangeType<Decimal>(); rhs = rightObj.ChangeType<Decimal>(); return lhs % rhs; } else { // bad } } else if (leftType == typeof(Double) || leftType == typeof(Double?) || rightType == typeof(Double) || rightType == typeof(Double?)) { Double lhs, rhs; lhs = leftObj.ChangeType<Double>(); rhs = rightObj.ChangeType<Double>(); return lhs % rhs; } else if (leftType == typeof(Single) || leftType == typeof(Single?) || rightType == typeof(Single) || rightType == typeof(Single?)) { Single lhs, rhs; lhs = leftObj.ChangeType<Single>(); rhs = rightObj.ChangeType<Single>(); return lhs % rhs; } else if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs % rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs % rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs % rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs % rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs % rhs; } } break; } case BinaryOperator.Band: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs & rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs & rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs & rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs & rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs & rhs; } } break; } case BinaryOperator.Bor: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs | rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs | rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs | rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs | rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs | rhs; } } break; } case BinaryOperator.Bxor: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if (leftType == typeof(UInt64) || leftType == typeof(UInt64?) || rightType == typeof(UInt64) || rightType == typeof(UInt64?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?) && leftType != typeof(Int64) && leftType != typeof(Int64?) && rightType != typeof(Int64) && rightType != typeof(Int64?)) { UInt64 lhs, rhs; lhs = leftObj.ChangeType<UInt64>(); rhs = rightObj.ChangeType<UInt64>(); return lhs ^ rhs; } else { // bad } } else if (leftType == typeof(Int64) || leftType == typeof(Int64?) || rightType == typeof(Int64) || rightType == typeof(Int64?)) { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs ^ rhs; } else if (leftType == typeof(UInt32) || leftType == typeof(UInt32?) || rightType == typeof(UInt32) || rightType == typeof(UInt32?)) { if (leftType != typeof(SByte) && leftType != typeof(SByte?) && rightType != typeof(SByte) && rightType != typeof(SByte?) && leftType != typeof(Int16) && leftType != typeof(Int16?) && rightType != typeof(Int16) && rightType != typeof(Int16?) && leftType != typeof(Int32) && leftType != typeof(Int32?) && rightType != typeof(Int32) && rightType != typeof(Int32?)) { UInt32 lhs, rhs; lhs = leftObj.ChangeType<UInt32>(); rhs = rightObj.ChangeType<UInt32>(); return lhs ^ rhs; } else { Int64 lhs, rhs; lhs = leftObj.ChangeType<Int64>(); rhs = rightObj.ChangeType<Int64>(); return lhs ^ rhs; } } else { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs ^ rhs; } } break; } case BinaryOperator.Bls: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if ((leftType == typeof(Int32) || leftType == typeof(Int32?)) && (rightType == typeof(Int32) || rightType == typeof(Int32?))) { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs << rhs; } } break; } case BinaryOperator.Brs: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if ((leftType == typeof(Int32) || leftType == typeof(Int32?)) && (rightType == typeof(Int32) || rightType == typeof(Int32?))) { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs >> rhs; } } break; } case BinaryOperator.Bsr: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if ((leftType == typeof(Int32) || leftType == typeof(Int32?)) && (rightType == typeof(Int32) || rightType == typeof(Int32?))) { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs >> rhs; } } break; } case BinaryOperator.Bur: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (numericTypes.Count(t => t == leftType) == 1 && numericTypes.Count(t => t == rightType) == 1) { if ((leftType == typeof(Int32) || leftType == typeof(Int32?)) && (rightType == typeof(Int32) || rightType == typeof(Int32?))) { Int32 lhs, rhs; lhs = leftObj.ChangeType<Int32>(); rhs = rightObj.ChangeType<Int32>(); return lhs >> rhs; } } break; } case BinaryOperator.StrLk: { if (leftType == typeof(String)) { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return false; rightType = rightObj.GetType(); if (rightType == typeof(String)) { string lhs, rhs; lhs = leftObj.ChangeType<string>(); rhs = rightObj.ChangeType<string>(); return lhs.Contains(rhs); } /*else { string lhs, rhs; lhs = leftObj.SafeToString(); rhs = rightObj.SafeToString(); return lhs.Contains(rhs); }*/ } break; } case BinaryOperator.And: { if (leftType == typeof(Boolean) || leftType == typeof(Boolean?)) { bool lhs; lhs = leftObj.ChangeType<bool>(); // short circuit evaluate if (!lhs) return false; rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (rightType == typeof(Boolean) || rightType == typeof(Boolean?)) { bool rhs; rhs = rightObj.ChangeType<bool>(); return rhs; } } break; } case BinaryOperator.Or: { if (leftType == typeof(Boolean) || leftType == typeof(Boolean?)) { bool lhs; lhs = leftObj.ChangeType<bool>(); // short circuit evaluate if (lhs) return true; rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (rightType == typeof(Boolean) || rightType == typeof(Boolean?)) { bool rhs; rhs = rightObj.ChangeType<bool>(); return rhs; } } break; } case BinaryOperator.Xor: { if (leftType == typeof(Boolean) || leftType == typeof(Boolean?)) { bool lhs; lhs = leftObj.ChangeType<bool>(); // no short circuit evaluate possible here rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (rightType == typeof(Boolean) || rightType == typeof(Boolean?)) { bool rhs; rhs = rightObj.ChangeType<bool>(); return (lhs && !rhs) || (rhs && !lhs); } } break; } case BinaryOperator.ObjAs: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (rightType == typeof(String)) { string rhs; rhs = rightObj.ChangeType<string>(); if (SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsWhiteSpace(rhs)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | dataTypeFascade.ReflectionFascadeLegacyInstance.IsNullOrWhiteSpace(rhs)"); rightType = Type.GetType(rhs, false); if ((object)rightType == null) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | Type.GetType"); return SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.ChangeType(leftObj, rightType); } break; } case BinaryOperator.Parse: { if (leftType == typeof(String)) { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (rightType == typeof(String)) { string lhs, rhs; object result; lhs = leftObj.ChangeType<string>(); rhs = rightObj.ChangeType<string>(); if (SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsWhiteSpace(rhs)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | dataTypeFascade.ReflectionFascadeLegacyInstance.IsNullOrWhiteSpace(rhs)"); rightType = Type.GetType(rhs, false); if ((object)rightType == null) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | Type.GetType"); if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.TryParse(rightType, lhs, out result)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | dataTypeFascade.ReflectionFascadeLegacyInstance.TryParse"); return result; } } break; } case BinaryOperator.ObjIs: { rightObj = onDemandRightExpressionEvaluator(); if ((object)rightObj == null) return null; rightType = rightObj.GetType(); if (rightType == typeof(String)) { string rhs; rhs = rightObj.ChangeType<string>(); if (SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsWhiteSpace(rhs)) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | dataTypeFascade.ReflectionFascadeLegacyInstance.IsNullOrWhiteSpace(rhs)"); rightType = Type.GetType(rhs, false); if ((object)rightType == null) throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | Type.GetType"); return rightType.IsAssignableFrom(leftType); } break; } case BinaryOperator.VarPut: { if (typeof(AspectConstruct).IsAssignableFrom(leftType)) { AspectConstruct lhs; IExpressionContainerConstruct expressionContainerConstruct; ValueConstruct valueConstruct; rightObj = onDemandRightExpressionEvaluator(); rightType = (object)rightObj != null ? rightObj.GetType() : null; lhs = leftObj.ChangeType<AspectConstruct>(); expressionContainerConstruct = new ExpressionContainerConstruct(); valueConstruct = new ValueConstruct() { Type = (object)rightType != null ? rightType.FullName : null, __ = rightObj }; ((IContentContainerXmlObject<IExpressionXmlObject>)expressionContainerConstruct).Content = valueConstruct; this.Assign(lhs.Name, expressionContainerConstruct, templatingContext); return rightObj; } break; } default: { throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | binary operator is not recognized"); } } throw new InvalidOperationException("(?) Something went wrong but the software engineers were too lazy to add a meaningful error message. | type is not supported by the binary operator"); }
protected override void CoreExpandTemplate(ITemplatingContext templatingContext) { string scopeName; bool appendMode; Encoding encoding; DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy; if ((object)templatingContext == null) throw new ArgumentNullException(nameof(templatingContext)); dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy(); scopeName = templatingContext.Tokenizer.ExpandTokens(this.ScopeName, dynamicWildcardTokenReplacementStrategy); appendMode = this.Append; if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(this.EncodingName)) encoding = Encoding.GetEncoding(this.EncodingName); else encoding = Encoding.UTF8; if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(scopeName)) { new AllocConstruct() { Token = "#OutputScopeName" }.ExpandTemplate(templatingContext); } if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(scopeName)) { IExpressionContainerConstruct expressionContainerConstruct; ValueConstruct valueConstruct; expressionContainerConstruct = new ExpressionContainerConstruct(); valueConstruct = new ValueConstruct() { Type = typeof(string).FullName, __ = scopeName }; ((IContentContainerXmlObject<IExpressionXmlObject>)expressionContainerConstruct).Content = valueConstruct; new AssignConstruct() { Token = "#OutputScopeName", Expression = expressionContainerConstruct }.ExpandTemplate(templatingContext); } templatingContext.Output.LogTextWriter.WriteLine("['{0:O}' (UTC)]\tEntering output scope '{1}'.", DateTime.UtcNow, scopeName); templatingContext.Output.EnterScope(scopeName, appendMode, encoding); if ((object)this.Items != null) { foreach (ITemplateMechanism templateMechanism in this.Items) templateMechanism.ExpandTemplate(templatingContext); } templatingContext.Output.LeaveScope(scopeName); templatingContext.Output.LogTextWriter.WriteLine("['{0:O}' (UTC)]\tLeaving output scope '{1}'.", DateTime.UtcNow, scopeName); if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(scopeName)) { new FreeConstruct() { Token = "#OutputScopeName" }.ExpandTemplate(templatingContext); } }
protected override void CoreExpandTemplate(ITemplatingContext templatingContext) { string aqtn; DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy; ISourceStrategy sourceStrategy; Type sourceStrategyType; string sourceFilePath, var; object source; if ((object)templatingContext == null) throw new ArgumentNullException(nameof(templatingContext)); dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy(); aqtn = templatingContext.Tokenizer.ExpandTokens(this.AssemblyQualifiedTypeName, dynamicWildcardTokenReplacementStrategy); sourceFilePath = templatingContext.Tokenizer.ExpandTokens(this.SourceFilePath, dynamicWildcardTokenReplacementStrategy); var = templatingContext.Tokenizer.ExpandTokens(this.Var, dynamicWildcardTokenReplacementStrategy); sourceStrategyType = Type.GetType(aqtn, false); if ((object)sourceStrategyType == null) throw new InvalidOperationException(string.Format("Failed to load the source strategy type '{0}' via Type.GetType(..).", aqtn)); if (!typeof(ISourceStrategy).IsAssignableFrom(sourceStrategyType)) throw new InvalidOperationException(string.Format("The source strategy type is not assignable to type '{0}'.", typeof(ISourceStrategy).FullName)); sourceStrategy = (ISourceStrategy)Activator.CreateInstance(sourceStrategyType); source = sourceStrategy.GetSourceObject(/*templatingContext, */sourceFilePath, templatingContext.Properties); if (!this.UseAlloc) { templatingContext.IteratorModels.Push(source); if ((object)this.Items != null) { foreach (ITemplateMechanism templateMechanism in this.Items) templateMechanism.ExpandTemplate(templatingContext); } templatingContext.IteratorModels.Pop(); } else { if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(var)) { IExpressionContainerConstruct expressionContainerConstruct; ValueConstruct valueConstruct; new AllocConstruct() { Token = var }.ExpandTemplate(templatingContext); expressionContainerConstruct = new ExpressionContainerConstruct(); valueConstruct = new ValueConstruct() { __ = source }; ((IContentContainerXmlObject<IExpressionXmlObject>)expressionContainerConstruct).Content = valueConstruct; new AssignConstruct() { Token = var, Expression = expressionContainerConstruct }.ExpandTemplate(templatingContext); } } }
protected override void CoreExpandTemplate(ITemplatingContext templatingContext) { string @in, varCt, varItem, varIx; uint count = 0, index = 1; // one-based IEnumerable values; object obj; DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy; if ((object)templatingContext == null) throw new ArgumentNullException(nameof(templatingContext)); dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy(); @in = templatingContext.Tokenizer.ExpandTokens(this.In, dynamicWildcardTokenReplacementStrategy); varItem = templatingContext.Tokenizer.ExpandTokens(this.VarItem, dynamicWildcardTokenReplacementStrategy); varCt = templatingContext.Tokenizer.ExpandTokens(this.VarCt, dynamicWildcardTokenReplacementStrategy); varIx = templatingContext.Tokenizer.ExpandTokens(this.VarIx, dynamicWildcardTokenReplacementStrategy); if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varItem)) { new AllocConstruct() { Token = varItem }.ExpandTemplate(templatingContext); } if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varCt)) { new AllocConstruct() { Token = varCt }.ExpandTemplate(templatingContext); } if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varIx)) { new AllocConstruct() { Token = varIx }.ExpandTemplate(templatingContext); } if (!dynamicWildcardTokenReplacementStrategy.GetByToken(@in, out obj)) throw new InvalidOperationException(string.Format("The facet name '{0}' was not found on the target model.", @in)); if ((object)obj == null) return; if (!(obj is IEnumerable)) throw new InvalidOperationException(string.Format("The in expression the for-each construct is not assignable to type '{0}'.", typeof(IEnumerable).FullName)); values = (IEnumerable)obj; obj = null; // not needed if ((object)this.Filter != null) { ArrayList temp; bool shouldFilter; temp = new ArrayList(); if ((object)values != null) { foreach (object value in values) { templatingContext.IteratorModels.Push(value); obj = this.Filter.EvaluateExpression(templatingContext); templatingContext.IteratorModels.Pop(); if ((object)obj != null && !(obj is bool) && !(obj is bool?)) throw new InvalidOperationException(string.Format("The for-each construct filter expression has evaluated to a non-null value with an unsupported type '{0}'; only '{1}' and '{2}' types are supported.", value.GetType().FullName, typeof(bool).FullName, typeof(bool?).FullName)); shouldFilter = !((bool)(obj ?? true)); if (!shouldFilter) { count++; temp.Add(value); } } } values = temp; } else { if ((object)values != null) { foreach (object value in values) count++; } } if ((object)this.Sort != null) values = this.Sort.EvaluateSort(templatingContext, values); if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varCt)) { IExpressionContainerConstruct expressionContainerConstruct; ValueConstruct valueConstruct; expressionContainerConstruct = new ExpressionContainerConstruct(); valueConstruct = new ValueConstruct() { Type = typeof(int).FullName, __ = count }; ((IContentContainerXmlObject<IExpressionXmlObject>)expressionContainerConstruct).Content = valueConstruct; new AssignConstruct() { Token = varCt, Expression = expressionContainerConstruct }.ExpandTemplate(templatingContext); } if ((object)values != null) { foreach (object value in values) { if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varItem)) { IExpressionContainerConstruct expressionContainerConstruct; ValueConstruct valueConstruct; expressionContainerConstruct = new ExpressionContainerConstruct(); valueConstruct = new ValueConstruct() { __ = value }; ((IContentContainerXmlObject<IExpressionXmlObject>)expressionContainerConstruct).Content = valueConstruct; new AssignConstruct() { Token = varItem, Expression = expressionContainerConstruct }.ExpandTemplate(templatingContext); } if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varIx)) { IExpressionContainerConstruct expressionContainerConstruct; ValueConstruct valueConstruct; expressionContainerConstruct = new ExpressionContainerConstruct(); valueConstruct = new ValueConstruct() { Type = typeof(int).FullName, __ = index }; ((IContentContainerXmlObject<IExpressionXmlObject>)expressionContainerConstruct).Content = valueConstruct; new AssignConstruct() { Token = varIx, Expression = expressionContainerConstruct }.ExpandTemplate(templatingContext); } templatingContext.IteratorModels.Push(value); if ((object)this.Body != null) this.Body.ExpandTemplate(templatingContext); templatingContext.IteratorModels.Pop(); index++; } if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varIx)) { new FreeConstruct() { Token = varIx }.ExpandTemplate(templatingContext); } if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varCt)) { new FreeConstruct() { Token = varCt }.ExpandTemplate(templatingContext); } if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varItem)) { new FreeConstruct() { Token = varItem }.ExpandTemplate(templatingContext); } } }
protected override void CoreExpandTemplate(ITemplatingContext templatingContext) { const uint MAX_ITERATIONS_INFINITE_LOOP_CHECK = 999999; string varIx; uint index = 1; // one-based DynamicWildcardTokenReplacementStrategy dynamicWildcardTokenReplacementStrategy; if ((object)templatingContext == null) throw new ArgumentNullException(nameof(templatingContext)); dynamicWildcardTokenReplacementStrategy = templatingContext.GetDynamicWildcardTokenReplacementStrategy(); varIx = templatingContext.Tokenizer.ExpandTokens(this.VarIx, dynamicWildcardTokenReplacementStrategy); if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varIx)) { new AllocConstruct() { Token = varIx }.ExpandTemplate(templatingContext); } this.CoreConditionalIterationInitialize(templatingContext); // DO NOT USE REAL FOR LOOP HERE while (true) { if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varIx)) { IExpressionContainerConstruct expressionContainerConstruct; ValueConstruct valueConstruct; expressionContainerConstruct = new ExpressionContainerConstruct(); valueConstruct = new ValueConstruct() { Type = typeof(int).FullName, __ = index }; ((IContentContainerXmlObject<IExpressionXmlObject>)expressionContainerConstruct).Content = valueConstruct; new AssignConstruct() { Token = varIx, Expression = expressionContainerConstruct }.ExpandTemplate(templatingContext); } if (index > MAX_ITERATIONS_INFINITE_LOOP_CHECK) throw new InvalidOperationException(string.Format("The conditional iteration construct has exceeded the maximun number of iterations '{0}'; this is an infinite loop prevention mechansim.", MAX_ITERATIONS_INFINITE_LOOP_CHECK)); if (this.Precondition) { if (!this.CheckCondition(templatingContext)) break; } if ((object)this.Body != null) this.Body.ExpandTemplate(templatingContext); this.CoreConditionalIterationStep(templatingContext, index); if (!this.Precondition) { if (!this.CheckCondition(templatingContext)) break; } index++; } this.CoreConditionalIterationTerminate(templatingContext); if (!SolderLegacyInstanceAccessor.DataTypeFascadeLegacyInstance.IsNullOrWhiteSpace(varIx)) { new FreeConstruct() { Token = varIx }.ExpandTemplate(templatingContext); } }