public override Value Execute(Args args, Environment environment, SourcePos pos) { var a = args.Get("a"); var b = args.Get("b"); if (a.IsNull() || b.IsNull()) { return(ValueNull.NULL); } if (a.IsInt() && b.IsInt()) { return(new ValueInt(a.AsInt().GetValue() + b.AsInt().GetValue())); } if (a.IsNumerical() && b.IsNumerical()) { return(new ValueDecimal(a.AsDecimal().GetValue() + b.AsDecimal().GetValue())); } if (a.IsList()) { if (b.IsCollection()) { return(new ValueList(a.AsList().GetValue()).AddItems(b.AsList().GetValue())); } return(new ValueList(a.AsList().GetValue()).AddItem(b)); } if (a.IsDate() && b.IsNumerical()) { return(new ValueDate(a.AsDate().GetValue() + TimeSpan.FromDays((double)args.GetAsDecimal("b").GetValue()))); } if (a.IsSet()) { if (b.IsCollection()) { return(new ValueSet(a.AsSet().GetValue()).AddItems(b.AsSet().GetValue())); } return(new ValueSet(a.AsSet().GetValue()).AddItem(b)); } if (b.IsList()) { var result = new ValueList(); result.AddItem(a); result.AddItems(b.AsList().GetValue()); return(result); } if (b.IsSet()) { var result = new ValueSet(); result.AddItem(a); result.AddItems(b.AsSet().GetValue()); return(result); } if (a.IsString() && b.IsAtomic() || a.IsAtomic() && b.IsString()) { return(new ValueString(a.AsString().GetValue() + b.AsString().GetValue())); } throw new ControlErrorException(new ValueString("ERROR"), "Cannot add " + a + " and " + b, pos); }