public override IQueryValue EvaluateOperator(IEnvironment env, IQueryValue left, IQueryValue right) { switch (left.GetIQLType()) { default: throw new ArgumentException(string.Format("Left side of + cannot be of type {0}", left.GetIQLType())); case IQLType.Number: switch (right.GetIQLType()) { default: throw new ArgumentException(string.Format("Right side of + cannot be of type {0} when left side is a number", right.GetIQLType())); case IQLType.Number: return new NumberValue() {Number = left.Number + right.Number}; case IQLType.Color: return new ColorValue() {Color = right.Color.Each(v => left.Number + v)}; } case IQLType.Color: switch (right.GetIQLType()) { default: throw new ArgumentException(string.Format("Right side of + cannot be of type {0} when left side is a color", right.GetIQLType())); case IQLType.Color: return new ColorValue() {Color = left.Color + right.Color}; case IQLType.Number: return new ColorValue() {Color = left.Color.Each(v => v + right.Number)}; } } }
public override IQueryValue EvaluateOperator(IEnvironment env, IQueryValue left, IQueryValue right) { switch (left.GetIQLType()) { default: throw new ArgumentException(string.Format("Arguments to < cannot be of type {0}", left.GetIQLType())); case IQLType.Number: return new BooleanValue() { Boolean = left.Number < right.Number }; } }
public static void SetValue(this IQueryValue l, IQueryValue r) { if (l.GetIQLType() != r.GetIQLType()) { throw new InvalidOperationException("Cannot set query value to disparate type"); } switch (l.GetIQLType()) { case IQLType.Number: l.Number = r.Number; break; case IQLType.Boolean: l.Boolean = r.Boolean; break; case IQLType.Canvas: l.Canvas = r.Canvas; break; case IQLType.Color: l.Color = r.Color.Clone(); break; } }
public override IQueryValue EvaluateOperator(IEnvironment env, IQueryValue left, IQueryValue right) { if (left.GetIQLType() != right.GetIQLType()) return new BooleanValue() {Boolean = false}; switch (left.GetIQLType()) { case IQLType.Number: return new BooleanValue() {Boolean = left.Number != right.Number}; case IQLType.Color: return new BooleanValue() {Boolean = !left.Color.Equals(right.Color)}; case IQLType.Canvas: return new BooleanValue() {Boolean = left.Canvas != right.Canvas}; case IQLType.Boolean: return new BooleanValue() {Boolean = left.Boolean != right.Boolean}; } return new BooleanValue() {Boolean = false}; }