public static JTokenType ConvertInterpreterTypeIntoJTokenType(IConstruct l)
        {
            string expectedValueType = l.GetType().Name;

            if (expectedValueType == "Variable")
            {
                Variable v = l as Variable;
                return(ConvertInterpreterTypeIntoJTokenType(v.Value));
            }
            if (expectedValueType == "Operation")
            {
                var r = l.Transform();
                return(ConvertInterpreterTypeIntoJTokenType(r));
            }
            if (expectedValueType == "FunctionOperation")
            {
                return(ConvertInterpreterTypeIntoJTokenType(l.Transform()));
            }
            if (expectedValueType == "Array")
            {
                return(JTokenType.Array);
            }
            if (expectedValueType == "Number")
            {
                return(JTokenType.Float);
            }
            if (expectedValueType == "Text")
            {
                return(JTokenType.String);
            }
            if (expectedValueType == "DateTime")
            {
                return(JTokenType.Date);
            }
            if (expectedValueType == "Boolean")
            {
                return(JTokenType.Boolean);
            }
            if (expectedValueType == "Null")
            {
                return(JTokenType.Null);
            }
            if (expectedValueType == "Array")
            {
                return(JTokenType.Array);
            }
            return(JTokenType.Undefined);
        }
        /// <summary>
        /// Returns the calculated value for the expression.
        /// Any variables should be set before calling this function.
        /// Will typically return a Number or Boolean literal value (depending on the type of expression).
        /// </summary>
        public override Literal Execute()
        {
            if (construct != null)
            {
                return(construct.Transform());
            }

            return(null);
        }
Exemple #3
0
        /// <summary>
        /// Gets the construct and transforms/executes it and returns it as of type T.
        /// If the transformed result is not of type T then an exception is thrown.
        /// Minimise the use of this function because it will traverse and execute the entire expression tree if the construct represents an operation or function.
        /// </summary>
        protected T GetTransformedConstruct <T>(IConstruct construct) where T : Literal
        {
            var transformedConstruct = construct.Transform();

            return(CastConstructToType <T>(transformedConstruct));
        }
        /// <summary>
        /// Returns the calculated value for the expression.
        /// Any variables should be set before calling this function.
        /// Will typically return a Number or Boolean literal value (depending on the type of expression).
        /// </summary>
        public override Literal Execute()
        {
            EnsureExpressionParsed();

            return(construct.Transform());
        }
 /// <summary>
 /// Returns the calculated value for the expression.
 /// Any variables should be set before calling this function.
 /// Will typically return a Number or Boolean literal value (depending on the type of expression).
 /// </summary>
 public override Literal Execute()
 {
     return(construct.Transform());
 }