• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Ast.LambdaExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: TrackedVisitLambdaExpression

		public virtual object TrackedVisitLambdaExpression(LambdaExpression lambdaExpression, object data) {
			return base.VisitLambdaExpression(lambdaExpression, data);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:3,代码来源:NodeTrackingAstVisitor.cs


示例17: VisitLambdaExpression

		public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
		{
			return CreateResolveResult(new LambdaReturnType(lambdaExpression, resolver));
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:4,代码来源:ResolveVisitor.cs


示例18: FunctionLambdaExpression

	void FunctionLambdaExpression(
#line  2264 "VBNET.ATG" 
out LambdaExpression lambda) {

#line  2266 "VBNET.ATG" 
		lambda = new LambdaExpression();
		TypeReference typeRef = null;
		Expression inner = null;
		Statement statement = null;
		lambda.StartLocation = la.Location;
		
		while (la.kind == 66 || la.kind == 148) {
			if (la.kind == 66) {
				lexer.NextToken();

#line  2273 "VBNET.ATG" 
				lambda.IsAsync = true; 
			} else {
				lexer.NextToken();

#line  2273 "VBNET.ATG" 
				lambda.IsIterator = true; 
			}
		}
		Expect(129);
		if (la.kind == 37) {
			lexer.NextToken();
			if (StartOf(6)) {
				FormalParameterList(
#line  2273 "VBNET.ATG" 
lambda.Parameters);
			}
			Expect(38);
		}
		if (la.kind == 63) {
			lexer.NextToken();
			TypeName(
#line  2274 "VBNET.ATG" 
out typeRef);

#line  2274 "VBNET.ATG" 
			lambda.ReturnType = typeRef; 
		}
		if (StartOf(43)) {
			if (StartOf(25)) {
				Expr(
#line  2277 "VBNET.ATG" 
out inner);

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

#line  2286 "VBNET.ATG" 
				lambda.StatementBody = statement;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;
				
			}
		} else if (la.kind == 1) {
			lexer.NextToken();
			Block(
#line  2293 "VBNET.ATG" 
out statement);
			Expect(115);
			Expect(129);

#line  2296 "VBNET.ATG" 
			lambda.StatementBody = statement;
			lambda.EndLocation = t.EndLocation;
			lambda.ExtendedEndLocation = la.Location;
			
		} else SynErr(301);
	}
开发者ID:BooMWax,项目名称:SharpDevelop,代码行数:80,代码来源:Parser.cs


示例19: SubLambdaExpression

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

#line  2228 "VBNET.ATG" 
		lambda = new LambdaExpression();
		lambda.ReturnType = new TypeReference("System.Void", true);
		Expression inner = null;
		Statement statement = null;
		lambda.StartLocation = la.Location;
		
		while (la.kind == 66 || la.kind == 148) {
			if (la.kind == 66) {
				lexer.NextToken();

#line  2235 "VBNET.ATG" 
				lambda.IsAsync = true; 
			} else {
				lexer.NextToken();

#line  2235 "VBNET.ATG" 
				lambda.IsIterator = true; 
			}
		}
		Expect(213);
		if (la.kind == 37) {
			lexer.NextToken();
			if (StartOf(6)) {
				FormalParameterList(
#line  2235 "VBNET.ATG" 
lambda.Parameters);
			}
			Expect(38);
		}
		if (StartOf(43)) {
			if (StartOf(25)) {
				Expr(
#line  2238 "VBNET.ATG" 
out inner);

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

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

#line  2257 "VBNET.ATG" 
			lambda.StatementBody = statement;
			lambda.EndLocation = t.EndLocation;
			lambda.ExtendedEndLocation = la.Location;
			
		} else SynErr(300);
	}
开发者ID:BooMWax,项目名称:SharpDevelop,代码行数:71,代码来源:Parser.cs


示例20: VisitQueryExpression

		public override object VisitQueryExpression(QueryExpression queryExpression, object data)
		{
			QueryExpressionSelectClause selectClause = queryExpression.SelectOrGroupClause as QueryExpressionSelectClause;
			QueryExpressionGroupClause groupClause = queryExpression.SelectOrGroupClause as QueryExpressionGroupClause;
			if (selectClause != null) {
				// Fake a call to 'Select'
				var fakeInvocation = new InvocationExpression(new MemberReferenceExpression(
					queryExpression.FromClause.InExpression, "Select"));
				
				var selector = new LambdaExpression();
				selector.Parameters.Add(new ParameterDeclarationExpression(null, "__rangeVariable"));
				selector.ExpressionBody = selectClause.Projection;
				selector.Parent = fakeInvocation;
				
				fakeInvocation.Arguments.Add(selector);
				
				return CreateResolveResult(ResolveType(fakeInvocation));
			} else if (groupClause != null) {
				// Fake a call to 'GroupBy'
				var fakeInvocation = new InvocationExpression(new MemberReferenceExpression(
					queryExpression.FromClause.InExpression, "GroupBy"));
				
				var keySelector = new LambdaExpression();
				keySelector.Parameters.Add(new ParameterDeclarationExpression(null, "__rangeVariable"));
				keySelector.ExpressionBody = groupClause.GroupBy;
				keySelector.Parent = fakeInvocation;
				
				var elementSelector = new LambdaExpression();
				elementSelector.Parameters.Add(new ParameterDeclarationExpression(null, "__rangeVariable"));
				elementSelector.ExpressionBody = groupClause.Projection;
				elementSelector.Parent = fakeInvocation;
				
				fakeInvocation.Arguments.Add(keySelector);
				fakeInvocation.Arguments.Add(elementSelector);
				
				return CreateResolveResult(ResolveType(fakeInvocation));
			} else {
				return null;
			}
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:40,代码来源:ResolveVisitor.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ast.LocalVariableDeclaration类代码示例发布时间:2022-05-26
下一篇:
C# Ast.InvocationExpression类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap