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


C# Expressions.InvocationExpression类代码示例

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


InvocationExpression类属于System.Linq.Expressions命名空间,在下文中一共展示了InvocationExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitInvocation

 protected override Expression VisitInvocation(InvocationExpression iv)
 {
     if (iv.Expression is LambdaExpression)
         return Visit(ExpressionReplacer.Replace(iv));
     else
         return base.VisitInvocation(iv); //Just calling a delegate in the projector
 }
开发者ID:signumsoftware,项目名称:framework,代码行数:7,代码来源:ExpressionCleaner.cs

示例2: UpdateInvocation

 protected InvocationExpression UpdateInvocation(InvocationExpression iv, Expression expression, IEnumerable<Expression> args)
 {
     if (args != iv.Arguments || expression != iv.Expression) {
         return Expression.Invoke(expression, args);
     }
     return iv;
 }
开发者ID:kpfaulkner,项目名称:Linq-To-Search,代码行数:7,代码来源:ExpressionVisitor.cs

示例3: VisitInvocation

        /// <summary>
        /// Flatten calls to Invoke so that Entity Framework can understand it. Calls to Invoke are generated
        /// by PredicateBuilder.
        /// </summary>
        protected override Expression VisitInvocation(InvocationExpression iv)
        {
            Expression target = iv.Expression;
            if (target is MemberExpression) target = TransformExpr ((MemberExpression)target);
            if (target is ConstantExpression) target = ((ConstantExpression)target).Value as Expression;

            LambdaExpression lambda = (LambdaExpression)target;

            Dictionary<ParameterExpression, Expression> replaceVars;
            if (_replaceVars == null)
                replaceVars = new Dictionary<ParameterExpression, Expression> ();
            else
                replaceVars = new Dictionary<ParameterExpression, Expression> (_replaceVars);

            try
            {
                for (int i = 0; i < lambda.Parameters.Count; i++)
                    replaceVars.Add (lambda.Parameters[i], iv.Arguments[i]);
            }
            catch (ArgumentException ex)
            {
                throw new InvalidOperationException ("Invoke cannot be called recursively - try using a temporary variable.", ex);
            }

            return new ExpressionExpander (replaceVars).Visit (lambda.Body);
        }
开发者ID:kaleylab,项目名称:KaleyLab,代码行数:30,代码来源:ExpressionExpander.cs

示例4: ParseInvocation

        private ExpressionNode ParseInvocation(InvocationExpression ie)
        {
            var args = new List<LiteralNode>();
            foreach(var arg in ie.Arguments)
            {
                if (arg is ParameterExpression)
                {
                    var name = ((ParameterExpression)arg).Name;
                    args.Add(new VariableNode(name));
                }
                else if (arg is ConstantExpression)
                {
                    var token = (String)((ConstantExpression)arg).Value;
                    args.Add(new ConstantNode(token));
                }
                else
                {
                    return Unsupported(arg);
                }
            }

            if (ie.Expression is MemberExpression)
            {
                var term = GetTermFromMemberExpression((MemberExpression)ie.Expression);
                return new TermNode(term, args.ToArray());
            }

            return Unsupported(ie);
        }
开发者ID:xeno-by,项目名称:rapt,代码行数:29,代码来源:LinqAstParser.cs

示例5: AssertInvokeIsOptimized

        private static void AssertInvokeIsOptimized(InvocationExpression expr, Expression expression, IReadOnlyList<Expression> args)
        {
            var n = args.Count;

            var updated = Update(expr);
            var visited = Visit(expr);

            foreach (var node in new[] { expr, updated, visited })
            {
                Assert.Same(expression, node.Expression);

                AssertInvocation(n, node);

                var argProvider = node as IArgumentProvider;
                Assert.NotNull(argProvider);

                Assert.Equal(n, argProvider.ArgumentCount);

                if (node != visited) // our visitor clones argument nodes
                {
                    for (var i = 0; i < n; i++)
                    {
                        Assert.Same(args[i], argProvider.GetArgument(i));
                        Assert.Same(args[i], node.Arguments[i]);
                    }
                }
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:28,代码来源:InvokeFactoryTests.cs

示例6: DoVisit

 private void DoVisit(InvocationExpression invocation)
 {
     foreach (var arg in invocation.Arguments)
     {
         Visit(arg);
     }
     Visit(invocation.Expression);
 }
开发者ID:Xamarui,项目名称:IdentityServer3.Contrib.ElasticSearchEventService,代码行数:8,代码来源:LambdaString.cs

示例7: VisitInvocation

 protected override Expression VisitInvocation(InvocationExpression node)
 {
     if (typeof(Delegate).IsAssignableFrom(node.Expression.Type) || IsObservableFuncType(node.Expression.Type, node.Arguments.Count))
     {
         return VisitMethodCall(Expression.Call(node.Expression, node.Expression.Type.GetMethod("Invoke"), node.Arguments));
     }
     throw new InvalidOperationException("Unclear what to invoke.");
 }
开发者ID:FrederikP,项目名称:NMF,代码行数:8,代码来源:ObservableExpressionBinder.Reflection.cs

示例8: UpdateInvocation

 protected static InvocationExpression UpdateInvocation(InvocationExpression node, Expression expression,
                                                        IEnumerable<Expression> args)
 {
     if (node.Arguments != args || node.Expression != expression)
     {
         return Expression.Invoke(expression, args);
     }
     return node;
 }
开发者ID:sprucemedia,项目名称:oinq,代码行数:9,代码来源:ExpressionVisitor.cs

示例9: InvocationExpectation

        /// <summary>
        /// Initializes a new instance of the <see cref="InvocationExpectation"/> class.
        /// </summary>
        /// <param name="lambdaExpression">The lambda expression.</param>
        public InvocationExpectation(LambdaExpression lambdaExpression)
        {
            var expression = lambdaExpression.Body as InvocationExpression;

            if (expression == null)
                throw new ArgumentException("Invalid lambda expression", "lambdaExpression");

            _expression = expression;
        }
开发者ID:mtamme,项目名称:NFake,代码行数:13,代码来源:InvocationExpectation.cs

示例10: Replace

        public static Expression Replace(InvocationExpression invocation)
        {
            LambdaExpression lambda = invocation.Expression as LambdaExpression;
            var replacer = new ExpressionReplacer()
            {
                replacements = 0.To(lambda.Parameters.Count).ToDictionaryEx(i => lambda.Parameters[i], i => invocation.Arguments[i])
            };

            return replacer.Visit(lambda.Body); 
        }
开发者ID:signumsoftware,项目名称:framework,代码行数:10,代码来源:ExpressionReplacer.cs

示例11: VisitInvocation

        protected override Expression VisitInvocation(InvocationExpression node)
        {
            var args = Visit(node.Arguments);
            foreach(var arg in args)
                AddParameter(arg);

            var expr = Visit(node.Expression);
            AddParameter(expr);
            return null;
        }
开发者ID:hazama-yuinyan,项目名称:Expresso,代码行数:10,代码来源:ParameterCollector.cs

示例12: ParseInvokationExpression

        private static ParsedCallExpression ParseInvokationExpression(InvocationExpression expression)
        {
            var target = Helpers.GetValueProducedByExpression(expression.Expression);
            var method = target.GetType().GetMethod("Invoke");

            return new ParsedCallExpression(
                calledMethod: method,
                callTargetExpression: expression.Expression,
                argumentsExpressions: from argument in expression.Arguments.Zip(method.GetParameters(), (x, y) => new { Expression = x, ParameterInfo = y })
                                      select new ParsedArgumentExpression(argument.Expression, argument.ParameterInfo));
        }
开发者ID:rajeshpillai,项目名称:FakeItEasy,代码行数:11,代码来源:CallExpressionParser.cs

示例13: VisitInvocation

 protected override Expression VisitInvocation(InvocationExpression node)
 {
     ConstantExpression varNameExpr;
     ParameterExpression contextExpr;
     if ((contextExpr = node.Expression as ParameterExpression) != null &&
         contextExpr.Name == _contextVarName &&
         node.Arguments.Count == 1 &&
         (varNameExpr = node.Arguments[0] as ConstantExpression) != null)
     {
         Variables.Add((string)varNameExpr.Value);
     }
     return base.VisitInvocation(node);
 }
开发者ID:wpq0,项目名称:Tiny-Expression-Evaluator,代码行数:13,代码来源:VariableEnumerator.cs

示例14: AutoInline

		internal Expression AutoInline(InvocationExpression expression)
		{
			this.isLocked = true;
			if (expression == null) throw new ArgumentNullException("expression");
			var lambda = (LambdaExpression) expression.Expression;
			var childScope = new ExpressionRewriter(this);
			var lambdaParams = lambda.Parameters;
			var invokeArgs = expression.Arguments;
			if (lambdaParams.Count != invokeArgs.Count) throw new InvalidOperationException("Lambda/invoke mismatch");
			for (int i = 0; i < lambdaParams.Count; i++)
			{
				childScope.Subst(lambdaParams[i], invokeArgs[i]);
			}
			return childScope.Apply(lambda.Body);
		}
开发者ID:trullock,项目名称:MuonKit.Csv,代码行数:15,代码来源:ExpressionRewriter.cs

示例15: VisitInvocation

        protected override Expression VisitInvocation(InvocationExpression node)
        {
            var baseResult = (InvocationExpression)base.VisitInvocation(node);

            if (baseResult.Expression.NodeType == ExpressionType.Call)
            {
                var methodCallExpression = (MethodCallExpression)baseResult.Expression;

                if (IsCompileMethod(methodCallExpression.Method))
                {
                    Expression result;
                    if (TrySubstituteExpression(methodCallExpression.Object, baseResult.Arguments, out result))
                        return result;
                }
            }

            return baseResult;
        }
开发者ID:IharBury,项目名称:expressions,代码行数:18,代码来源:ExpressionExpander.cs


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