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


C# Ast.LambdaExpression类代码示例

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


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

示例1: ModifyLambdaForSelectMany

		private static INode ModifyLambdaForSelectMany(LambdaExpression lambdaExpression,
		                                               ParenthesizedExpression parenthesizedlambdaExpression,
		                                               InvocationExpression invocationExpression)
		{
			INode node = lambdaExpression;
			var argPos = invocationExpression.Arguments.IndexOf(lambdaExpression);
			switch (argPos)
			{
				case 0: // first one, select the collection
					// need to enter a cast for (IEnumerable<dynamic>) on the end of the lambda body
					var selectManyExpression = new LambdaExpression
					{
						ExpressionBody =
							new CastExpression(new TypeReference("IEnumerable<dynamic>"),
							                   new ParenthesizedExpression(lambdaExpression.ExpressionBody), CastType.Cast),
						Parameters = lambdaExpression.Parameters,
					};
					node = new CastExpression(new TypeReference("Func<dynamic, IEnumerable<dynamic>>"),
					                          new ParenthesizedExpression(selectManyExpression), CastType.Cast);
					break;
				case 1: // the transformation func
					node = new CastExpression(new TypeReference("Func<dynamic, dynamic, dynamic>"), parenthesizedlambdaExpression,
					                          CastType.Cast);
					break;
			}
			return node;
		}
开发者ID:NuvemNine,项目名称:ravendb,代码行数:27,代码来源:TransformDynamicLambdaExpressions.cs

示例2: VisitLambdaExpression

		public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
		{
			if (lambdaExpression.StatementBody == null || lambdaExpression.StatementBody.IsNull)
				return base.VisitLambdaExpression(lambdaExpression, data);
			var text = QueryParsingUtils.ToText(lambdaExpression);
			throw new SecurityException("Lambda expression can only consist of a single expression, not a statement, but got: " + text);
		}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:7,代码来源:ThrowOnInvalidMethodCalls.cs

示例3: LocalLookupVariable

		public LocalLookupVariable(string name, TypeReference typeRef, Location startPos, Location endPos, bool isConst, bool isLoopVariable, Expression initializer, LambdaExpression parentLambdaExpression)
		{
			this.Name = name;
			this.TypeRef = typeRef;
			this.StartPos = startPos;
			this.EndPos = endPos;
			this.IsConst = isConst;
			this.IsLoopVariable = isLoopVariable;
			this.Initializer = initializer;
			this.ParentLambdaExpression = parentLambdaExpression;
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:11,代码来源:LookupTableVisitor.cs

示例4: VisitAnonymousMethodExpression

 public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
 {
     base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
     if (anonymousMethodExpression.Body.Children.Count == 1) {
         ReturnStatement rs = anonymousMethodExpression.Body.Children[0] as ReturnStatement;
         if (rs != null) {
             LambdaExpression lambda = new LambdaExpression();
             lambda.ExpressionBody = rs.Expression;
             lambda.Parameters = anonymousMethodExpression.Parameters;
             ReplaceCurrentNode(lambda);
         }
     }
     return null;
 }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:14,代码来源:ToVBNetConvertVisitor.cs

示例5: AddDocumentIdFieldToLambdaIfCreatingNewObject

        private static void AddDocumentIdFieldToLambdaIfCreatingNewObject(LambdaExpression lambdaExpression)
        {
            if (lambdaExpression.ExpressionBody is ObjectCreateExpression == false)
                return;
            var objectInitializer = ((ObjectCreateExpression)lambdaExpression.ExpressionBody).ObjectInitializer;

            var identifierExpression = new IdentifierExpression(lambdaExpression.Parameters[0].ParameterName);
            objectInitializer.CreateExpressions.Add(
                new NamedArgumentExpression
                {
                    Name = "__document_id",
                    Expression = new MemberReferenceExpression(identifierExpression, "__document_id")
                });
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:14,代码来源:DynamicViewCompiler.cs

示例6: LambdaParameterReturnType

		public LambdaParameterReturnType(LambdaExpression lambda, string name, NRefactoryResolver resolver)
		{
			if (lambda == null)
				throw new ArgumentNullException("lambda");
			if (name == null)
				throw new ArgumentNullException("name");
			if (resolver == null)
				throw new ArgumentNullException("resolver");
			this.lambda = lambda;
			this.parameterName = name;
			this.parameterIndex = lambda.Parameters.FindIndex(p => p.ParameterName == name);
			this.resolver = resolver;
			if (parameterIndex < 0)
				throw new ArgumentException("there is no lambda parameter with that name");
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:15,代码来源:LambdaParameterReturnType.cs

示例7: LambdaReturnType

		internal LambdaReturnType(LambdaExpression expression, NRefactoryResolver resolver)
			: base(resolver.CompilationUnit)
		{
			this.resolver = resolver;
			this.lambdaExpression = expression;
			
			base.MethodParameters = new List<IParameter>();
			foreach (ParameterDeclarationExpression param in expression.Parameters) {
				base.MethodParameters.Add(NRefactoryASTConvertVisitor.CreateParameter(param, resolver.CallingMember as IMethod, resolver.CallingClass, resolver.CompilationUnit));
			}
			if (expression.ExpressionBody.IsNull)
				expression.StatementBody.AcceptVisitor(new ReturnStatementFinder(returnExpressions), null);
			else
				returnExpressions.Add(expression.ExpressionBody);
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:15,代码来源:LambdaReturnType.cs

示例8: AddVariable

		public void AddVariable(TypeReference typeRef, string name,
		                        Location startPos, Location endPos, bool isConst,
		                        bool isLoopVariable, Expression initializer,
		                        LambdaExpression parentLambdaExpression)
		{
			if (name == null || name.Length == 0) {
				return;
			}
			List<LocalLookupVariable> list;
			if (!variables.ContainsKey(name)) {
				variables[name] = list = new List<LocalLookupVariable>();
			} else {
				list = (List<LocalLookupVariable>)variables[name];
			}
			list.Add(new LocalLookupVariable(name, typeRef, startPos, endPos, isConst, isLoopVariable, initializer, parentLambdaExpression));
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:16,代码来源:LookupTableVisitor.cs

示例9: LambdaExpr

	void LambdaExpr(
#line  1995 "VBNET.ATG" 
out Expression expr) {

#line  1997 "VBNET.ATG" 
		Expression inner = null;
		LambdaExpression lambda = new LambdaExpression();
		lambda.StartLocation = la.Location;
		
		Expect(114);
		if (la.kind == 25) {
			lexer.NextToken();
			if (StartOf(4)) {
				FormalParameterList(
#line  2003 "VBNET.ATG" 
lambda.Parameters);
			}
			Expect(26);
		}
		Expr(
#line  2004 "VBNET.ATG" 
out inner);

#line  2006 "VBNET.ATG" 
		lambda.ExpressionBody = inner;
		lambda.EndLocation = t.EndLocation; // la.Location?
		
		expr = lambda;
		
	}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:30,代码来源:Parser.cs

示例10: VisitLambdaExpression

		public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
		{
			foreach (ParameterDeclarationExpression p in lambdaExpression.Parameters) {
				AddVariable(p.TypeReference, p.ParameterName,
				            lambdaExpression.StartLocation, lambdaExpression.ExtendedEndLocation,
				            false, false, null, lambdaExpression, false, lambdaExpression.StartLocation);
			}
			return base.VisitLambdaExpression(lambdaExpression, data);
		}
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:9,代码来源:LookupTableVisitor.cs

示例11: VisitAnonymousMethodExpression

		public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
		{
			base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
			LambdaExpression lambda = new LambdaExpression();
			lambda.Parameters = anonymousMethodExpression.Parameters;
			if (anonymousMethodExpression.Body.Children.Count == 1) {
				ReturnStatement rs = anonymousMethodExpression.Body.Children[0] as ReturnStatement;
				if (rs != null)
					lambda.ExpressionBody = rs.Expression;
				else {
					lambda.StatementBody = anonymousMethodExpression.Body.Children[0] as Statement;
					lambda.ReturnType = new TypeReference("System.Void", true);
				}
			} else {
				var visitor = new ReturnStatementVisitor();
				anonymousMethodExpression.AcceptVisitor(visitor, null);
				lambda.StatementBody = anonymousMethodExpression.Body;
				if (!visitor.HasReturn)
					lambda.ReturnType = new TypeReference("System.Void", true);
			}
			ReplaceCurrentNode(lambda);
			return null;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:23,代码来源:ToVBNetConvertVisitor.cs

示例12: LambdaExpressionBody

	void LambdaExpressionBody(
#line  2174 "cs.ATG" 
LambdaExpression lambda) {

#line  2175 "cs.ATG" 
		Expression expr; BlockStatement stmt; 
		if (la.kind == 16) {
			Block(
#line  2178 "cs.ATG" 
out stmt);

#line  2178 "cs.ATG" 
			lambda.StatementBody = stmt; 
		} else if (StartOf(6)) {
			Expr(
#line  2179 "cs.ATG" 
out expr);

#line  2179 "cs.ATG" 
			lambda.ExpressionBody = expr; 
		} else SynErr(214);

#line  2181 "cs.ATG" 
		lambda.EndLocation = t.EndLocation; 

#line  2182 "cs.ATG" 
		lambda.ExtendedEndLocation = la.Location; 
	}
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:28,代码来源:Parser.cs

示例13: SubLambdaExpression

	void SubLambdaExpression(
//#line  2219 "VBNET.ATG" 
out LambdaExpression lambda) {

//#line  2221 "VBNET.ATG" 
		lambda = new LambdaExpression();
		lambda.ReturnType = new TypeReference("System.Void", true);
		Expression inner = null;
		Statement statement = null;
		lambda.StartLocation = la.Location;
		
		Expect(210);
		if (la.kind == 37) {
			lexer.NextToken();
			if (StartOf(6)) {
				FormalParameterList(
//#line  2228 "VBNET.ATG" 
lambda.Parameters);
			}
			Expect(38);
		}
		if (StartOf(42)) {
			if (StartOf(24)) {
				Expr(
//#line  2231 "VBNET.ATG" 
out inner);

//#line  2233 "VBNET.ATG" 
				lambda.ExpressionBody = inner;
				lambda.EndLocation = t.EndLocation; // la.Location?
				lambda.ExtendedEndLocation = la.Location;
				
			} else {
				EmbeddedStatement(
//#line  2238 "VBNET.ATG" 
out statement);

//#line  2240 "VBNET.ATG" 
				lambda.StatementBody = statement;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;
				
			}
		} else if (la.kind == 1) {
			lexer.NextToken();
			Block(
//#line  2247 "VBNET.ATG" 
out statement);
			Expect(113);
			Expect(210);

//#line  2250 "VBNET.ATG" 
			lambda.StatementBody = statement;
			lambda.EndLocation = t.EndLocation;
			lambda.ExtendedEndLocation = la.Location;
			
		} else SynErr(296);
	}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:58,代码来源:Parser.cs

示例14: ModifyLambdaForMinMax

		private static INode ModifyLambdaForMinMax(LambdaExpression lambdaExpression,
		                                           ParenthesizedExpression parenthesizedlambdaExpression)
		{
			var node = new CastExpression(new TypeReference("Func<dynamic, int>"), parenthesizedlambdaExpression, CastType.Cast);
			var castExpression = lambdaExpression.ExpressionBody as CastExpression;
			if (castExpression != null)
			{
				node = new CastExpression(new TypeReference("Func", new List<TypeReference>
				{
					new TypeReference("dynamic"),
					castExpression.CastTo
				}), parenthesizedlambdaExpression, CastType.Cast);
			}
			return node;
		}
开发者ID:NuvemNine,项目名称:ravendb,代码行数:15,代码来源:TransformDynamicLambdaExpressions.cs

示例15: LambdaExpressionBody

	void LambdaExpressionBody(
#line  2147 "Frames/cs.ATG" 
LambdaExpression lambda) {

#line  2148 "Frames/cs.ATG" 
		Expression expr; BlockStatement stmt; 
		if (la.kind == 16) {
			BlockInsideExpression(
#line  2151 "Frames/cs.ATG" 
out stmt);

#line  2151 "Frames/cs.ATG" 
			lambda.StatementBody = stmt; 
		} else if (StartOf(6)) {
			Expr(
#line  2152 "Frames/cs.ATG" 
out expr);

#line  2152 "Frames/cs.ATG" 
			lambda.ExpressionBody = expr; 
		} else SynErr(214);

#line  2154 "Frames/cs.ATG" 
		lambda.EndLocation = t.EndLocation; 

#line  2155 "Frames/cs.ATG" 
		lambda.ExtendedEndLocation = la.Location; 
	}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:28,代码来源:Parser.cs


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