当前位置: 首页>>代码示例>>C#>>正文


C# Expression.Interpret方法代码示例

本文整理汇总了C#中Expression.Interpret方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.Interpret方法的具体用法?C# Expression.Interpret怎么用?C# Expression.Interpret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Expression的用法示例。


在下文中一共展示了Expression.Interpret方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Handle

        public override Value Handle(Expression left, Expression right, IDictionary<String, Value> symbols)
        {
            var l = left.Interpret(symbols);
            var symbol = right as SymbolExpression;
            var value = default(StringValue);

            //Is it a Method Call?
            if (symbol == null)
            {
                var contExp = right as ContainerExpression;
                if (contExp != null)
                {
                    if (contExp.Expressions != null && contExp.Expressions.Length == 1 && contExp.Expressions[0] is SymbolExpression)
                    {
                        symbol = contExp.Expressions[0] as SymbolExpression;
                        var op = contExp.Operator as ArgsOperator;
                        if (op != null)
                        {
                            return op.Handle(symbol, symbols, l);
                        }
                        //YAMPMemberFunctionMissingException
                    }
                }
            }

            if (symbol != null)
            {
                value = new StringValue(symbol.SymbolName);
            }

            if (value == null)
                throw new YAMPFunctionMissingException("()");

            return Perform(l, value);
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:35,代码来源:MemberOperator.cs

示例2: Handle

 public override Value Handle(Expression expression, IDictionary<String, Value> symbols)
 {
     var a = PlusAssignmentOperator.CreateWithContext(Query);
     var origin = expression.Interpret(symbols);
     a.Handle(expression, new NumberExpression(ScalarValue.One), symbols);
     return origin;
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:7,代码来源:PostIncOperator.cs

示例3: Handle

        public override Value Handle(Expression left, Expression right, IDictionary<String, Value> symbols)
        {
            var l = left.Interpret(symbols);
            var r = new StringValue(End) as Value;
            var symbol = right as SymbolExpression;

            if (symbol == null || !symbol.SymbolName.Equals(End))
            {
                r = right.Interpret(symbols);
            }

            return Perform(l, r);
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:13,代码来源:RangeOperator.cs

示例4: Handle

        public override Value Handle(Expression expression, IDictionary<String, Value> symbols)
        {
            var args = _content.Interpret(symbols);
            var left = expression.Interpret(symbols);

            if (left is IFunction)
            {
                return ((IFunction)left).Perform(Context, args);
            }

            if (expression is SymbolExpression)
            {
                throw new YAMPFunctionMissingException(((SymbolExpression)expression).SymbolName);
            }

            throw new YAMPExpressionNoFunctionException();
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:17,代码来源:ArgsOperator.cs

示例5: Handle

 public override Value Handle(Expression value, IDictionary<String, Value> symbols)
 {
     var a = MinusAssignmentOperator.CreateWithContext(Query);
     a.Handle(value, new NumberExpression(ScalarValue.One), symbols);
     return value.Interpret(symbols);
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:6,代码来源:PreDecOperator.cs

示例6: Handle

 /// <summary>
 /// Handles the evaluation of two expressions.
 /// </summary>
 /// <param name="left">The expression on the left.</param>
 /// <param name="right">The expression on the right.</param>
 /// <param name="symbols">The external symbols to consider.</param>
 /// <returns>The result of the operation.</returns>
 public virtual Value Handle(Expression left, Expression right, IDictionary<String, Value> symbols)
 {
     var l = left.Interpret(symbols);
     var r = right.Interpret(symbols);
     return Perform(l, r);
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:13,代码来源:BinaryOperator.cs

示例7: Handle

 /// <summary>
 /// Handles the evaluation of one expression.
 /// </summary>
 /// <param name="expression">The expression on the left.</param>
 /// <param name="symbols">The external symbols to consider.</param>
 /// <returns>The result of the operation.</returns>
 public virtual Value Handle(Expression expression, IDictionary<String, Value> symbols)
 {
     var value = expression.Interpret(symbols);
     return Perform(value);
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:11,代码来源:UnaryOperator.cs

示例8: Handle

 public override Value Handle(Expression left, Expression right, IDictionary<String, Value> symbols)
 {
     var bottom = right.Interpret(symbols);
     return Assign(left, bottom, symbols);
 }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:5,代码来源:AssignmentOperator.cs

示例9: SetPerform

        void SetPerform(String name, String[] arguments, Expression body)
        {
            _perform = (context, argument) =>
            {
                var symbols = new Dictionary<String, Value>();
                var av = new ArgumentsValue().Append(argument);

                if (av.Length != arguments.Length)
                {
                    throw new YAMPArgumentNumberException(name, av.Length, arguments.Length);
                }

                for (var i = 0; i < arguments.Length; i++)
                {
                    symbols.Add(arguments[i], av.Values[i].Copy());
                }

                return body.Interpret(symbols);
            };
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:20,代码来源:FunctionValue.cs


注:本文中的Expression.Interpret方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。