Exemplo n.º 1
0
        public object Execute(VariableContext context = null)
        {
            var leftVal  = this.Left.Execute(context);
            var rightVal = this.Right.Execute(context);

            if (leftVal is Variable l && rightVal is Variable r)
            {
                if (l.ValueType != r.ValueType)
                {
                    throw new FEELException("The variable type does not match for the arithmetic action");
                }
                switch (l.ValueType)
                {
                case DataTypeEnum.Decimal:
                    return(new Variable(l.NumericVal + r.NumericVal));

                case DataTypeEnum.String:
                    return(new Variable($"{l.StringVal}{r.StringVal}"));

                case DataTypeEnum.Date:
                case DataTypeEnum.DateTime:
                case DataTypeEnum.Time:
                case DataTypeEnum.YearMonthDuration:
                case DataTypeEnum.DayTimeDuration:
                    return(DateAndTimeHelper.Addition(l, r));

                default:
                    throw new FEELException("Failed to perform addition to incorrect FEEL type");
                }
            }

            throw new FEELException("Failed to perform addition due to values not being a variable");
        }