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


C# Expression.Reduce方法代码示例

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


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

示例1: CompileExtensionExpression

        private void CompileExtensionExpression(Expression expr) {
            var instructionProvider = expr as IInstructionProvider;
            if (instructionProvider != null) {
                AddInstruction(instructionProvider.GetInstruction(this));
                return;
            }

            var node = expr as Microsoft.Scripting.Ast.SymbolConstantExpression;
            if (node != null) {
                PushConstant(node.Value);
                return;
            }

            if (expr.CanReduce) {
                Compile(expr.Reduce());
            } else {
                throw new System.NotImplementedException();
            }
        }
开发者ID:bclubb,项目名称:ironruby,代码行数:19,代码来源:LightCompiler.cs

示例2: CompileExtensionExpression

 private void CompileExtensionExpression(Expression expr)
 {
     IInstructionProvider provider = expr as IInstructionProvider;
     if (provider != null)
     {
         provider.AddInstructions(this);
     }
     else
     {
         if (!expr.CanReduce)
         {
             throw new NotImplementedException();
         }
         this.Compile(expr.Reduce());
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:16,代码来源:LightCompiler.cs

示例3: Visit

 public override Expression Visit(Expression node)
     => node != null
        && node.CanReduce
         ? Visit(node.Reduce())
         : base.Visit(node);
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:5,代码来源:ReducingExpressionVisitor.cs

示例4: CompileImpl

        private object CompileImpl(Expression expression, CompilerState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            state.RawReturnType = expression.Type;

            while (expression.CanReduce)
            {
                expression = expression.Reduce();
            }

            LambdaExpression lambda;
            var paramTypes = state.CompileToAction ? new Type[state.Arguments.Count] : new Type[state.Arguments.Count + 1];
            for (var i = 0; i < state.Arguments.Count; i++)
            {
                paramTypes[i] = state.Arguments[i].Type;
            }

            if (state.CompileToAction)
            {
                lambda = Expression.Lambda(Expression.GetActionType(paramTypes), expression, state.Arguments);
            }
            else
            {
                var returnType = state.ReturnType ?? state.RawReturnType;
                paramTypes[paramTypes.Length - 1] = returnType;

                expression = ExpressionTreeExtensions.AdjustReturnType(null, expression, returnType);
                lambda = Expression.Lambda(expression, state.Arguments);

                if (!ReferenceEquals(returnType, lambda.ReturnType))
                {
                    throw new CompilationException(string.Format("Expected return type: {0}. Real return type: {1}", returnType.FullName, lambda.ReturnType.FullName));
                }
            }

            if (lambda.Parameters.Count != state.Arguments.Count)
            {
                throw new CompilationException(string.Format("Expected number of arguments: {0}. Real number: {1}", state.Arguments.Count, lambda.Parameters.Count));
            }

            for (var i = 0; i < lambda.Parameters.Count; i++)
            {
                if (!ReferenceEquals(lambda.Parameters[i].Type, state.Arguments[i].Type))
                {
                    throw new CompilationException(
                        string.Format("Expected type of argument {0}: {1}. Real type: {2}", i, state.Arguments[i].Type.FullName, lambda.Parameters[i].Type.FullName));
                }
            }

            return lambda.Compile();
        }
开发者ID:adrobyazko-softheme,项目名称:PQL,代码行数:55,代码来源:ExpressionEvaluatorRuntime(Compiler).cs

示例5: VisitReducible

 public Expression VisitReducible(Expression node)
 {
     Debug.Assert(node.CanReduce);
     return Visit(node.Reduce());
 }
开发者ID:runerei,项目名称:Cartographer,代码行数:5,代码来源:ReduceExpressionVisitor.cs


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