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

C# Ast.ParenthesizedExpression类代码示例

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

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



ParenthesizedExpression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了ParenthesizedExpression类的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: GetCastExpression

        private CastExpression GetCastExpression(BinaryOperatorExpression binaryOperatorExpression)
        {
            TypeReference leftType = GetExpressionType(binaryOperatorExpression.Left);

            CastExpression castedUnsignedShift = new CastExpression(new TypeReference("u" + leftType.Type), binaryOperatorExpression, CastType.Cast);
            ParenthesizedExpression parenthesizedCastedUnsignedShift = new ParenthesizedExpression(castedUnsignedShift);
            return new CastExpression(new TypeReference(leftType.Type), parenthesizedCastedUnsignedShift, CastType.Cast);
        }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:8,代码来源:UnsignedShiftTransformer.cs


示例3: BuildCondition

		/// <summary>
		/// Turns "(a.b as T).d.e" into "(a != null) && (a.b is T) && ((a.b as T).d != null)"
		/// </summary>
		Expression BuildCondition(Expression targetExpr)
		{
			var parts = GetConditionParts(targetExpr);
			Expression condition = null;
			foreach (var part in parts) {
				if (condition == null) {
					// first
					condition = new ParenthesizedExpression(part);
				} else {
					condition = new BinaryOperatorExpression(new ParenthesizedExpression(part), BinaryOperatorType.LogicalAnd, condition);
				}
			}
			return condition;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:17,代码来源:CheckMemberNotNull.cs


示例4: ModifyLambdaForSelect

		private static INode ModifyLambdaForSelect(ParenthesizedExpression parenthesizedlambdaExpression,
		                                           MemberReferenceExpression target)
		{
			var parentInvocation = target.TargetObject as InvocationExpression;
			if(parentInvocation != null)
			{
				var parentTarget = parentInvocation.TargetObject as MemberReferenceExpression;
				if(parentTarget != null && parentTarget.MemberName == "GroupBy")
				{
					return new CastExpression(new TypeReference("Func<IGrouping<dynamic,dynamic>, dynamic>"), parenthesizedlambdaExpression, CastType.Cast);
				}
			}
			return new CastExpression(new TypeReference("Func<dynamic, dynamic>"), parenthesizedlambdaExpression, CastType.Cast);
		}
开发者ID:NuvemNine,项目名称:ravendb,代码行数:14,代码来源:TransformDynamicLambdaExpressions.cs


示例5: VisitLambdaExpression

		public override object VisitLambdaExpression(ICSharpCode.NRefactory.Ast.LambdaExpression lambdaExpression, object data)
		{
			var invocationExpression = lambdaExpression.Parent as InvocationExpression;
			if (invocationExpression == null)
				return base.VisitLambdaExpression(lambdaExpression, data);

			var target = invocationExpression.TargetObject as MemberReferenceExpression;
			if(target == null)
				return base.VisitLambdaExpression(lambdaExpression, data);

			INode node = lambdaExpression;
			var parenthesizedlambdaExpression = new ParenthesizedExpression(lambdaExpression);
			switch (target.MemberName)
			{
				case "Sum":
				case "Average":
					node = ModifyLambdaForNumerics(lambdaExpression, parenthesizedlambdaExpression);
					break;
				case "Max":
				case "Min":
					node = ModifyLambdaForMinMax(lambdaExpression, parenthesizedlambdaExpression);
					break;
				case "OrderBy":
				case "OrderByDescending":
				case "GroupBy":
				case "Recurse":
				case "Select":
					node = ModifyLambdaForSelect(parenthesizedlambdaExpression, target);
					break;
				case "SelectMany":
					node = ModifyLambdaForSelectMany(lambdaExpression, parenthesizedlambdaExpression, invocationExpression);
					break;
				case "Any":
				case "all":
				case "First":
				case "FirstOrDefault":
				case "Last":
				case "LastOfDefault":
				case "Single":
				case "Where":
				case "Count":
				case "SingleOrDefault":
					node = new CastExpression(new TypeReference("Func<dynamic, bool>"), parenthesizedlambdaExpression, CastType.Cast);
				break;
			}
			ReplaceCurrentNode(node);

			return base.VisitLambdaExpression(lambdaExpression, data);
		}
开发者ID:NuvemNine,项目名称:ravendb,代码行数:49,代码来源:TransformDynamicLambdaExpressions.cs


示例6: GenerateCode

		public override void GenerateCode(List<AbstractNode> nodes, IList items)
		{
			TypeReference intReference = new TypeReference("System.Int32");
			MethodDeclaration method = new MethodDeclaration("GetHashCode", Modifiers.Public | Modifiers.Override, intReference, null, null);
			Expression expr = CallGetHashCode(new IdentifierExpression(currentClass.Fields[0].Name));
			for (int i = 1; i < currentClass.Fields.Count; i++) {
				IdentifierExpression identifier = new IdentifierExpression(currentClass.Fields[i].Name);
				expr = new BinaryOperatorExpression(expr, BinaryOperatorType.ExclusiveOr,
				                                    CallGetHashCode(identifier));
			}
			method.Body = new BlockStatement();
			method.Body.AddChild(new ReturnStatement(expr));
			nodes.Add(method);
			
			TypeReference boolReference = new TypeReference("System.Boolean");
			TypeReference objectReference = new TypeReference("System.Object");
			
			method = new MethodDeclaration("Equals", Modifiers.Public | Modifiers.Override, boolReference, null, null);
			method.Parameters.Add(new ParameterDeclarationExpression(objectReference, "obj"));
			method.Body = new BlockStatement();
			
			TypeReference currentType = ConvertType(currentClass.DefaultReturnType);
			expr = new TypeOfIsExpression(new IdentifierExpression("obj"), currentType);
			expr = new ParenthesizedExpression(expr);
			expr = new UnaryOperatorExpression(expr, UnaryOperatorType.Not);
			method.Body.AddChild(new IfElseStatement(expr, new ReturnStatement(new PrimitiveExpression(false, "false"))));
			
			expr = new BinaryOperatorExpression(new ThisReferenceExpression(),
			                                    BinaryOperatorType.Equality,
			                                    new IdentifierExpression("obj"));
			method.Body.AddChild(new IfElseStatement(expr, new ReturnStatement(new PrimitiveExpression(true, "true"))));
			
			VariableDeclaration var = new VariableDeclaration("my" + currentClass.Name,
			                                                  new CastExpression(currentType, new IdentifierExpression("obj"), CastType.Cast),
			                                                  currentType);
			method.Body.AddChild(new LocalVariableDeclaration(var));
			
			expr = TestEquality(var.Name, currentClass.Fields[0]);
			for (int i = 1; i < currentClass.Fields.Count; i++) {
				expr = new BinaryOperatorExpression(expr, BinaryOperatorType.LogicalAnd,
				                                    TestEquality(var.Name, currentClass.Fields[i]));
			}
			
			method.Body.AddChild(new ReturnStatement(expr));
			
			nodes.Add(method);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:47,代码来源:EqualsCodeGenerator.cs


示例7: TrackedVisitParenthesizedExpression

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


示例8: SimpleNonInvocationExpression

	void SimpleNonInvocationExpression(
#line  1645 "VBNET.ATG" 
out Expression pexpr) {

#line  1647 "VBNET.ATG" 
		Expression expr;
		TypeReference type = null;
		string name = String.Empty;
		pexpr = null;
		
		if (StartOf(32)) {
			switch (la.kind) {
			case 3: {
				lexer.NextToken();

#line  1655 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 4: {
				lexer.NextToken();

#line  1656 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 7: {
				lexer.NextToken();

#line  1657 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 6: {
				lexer.NextToken();

#line  1658 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 5: {
				lexer.NextToken();

#line  1659 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 9: {
				lexer.NextToken();

#line  1660 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 8: {
				lexer.NextToken();

#line  1661 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 202: {
				lexer.NextToken();

#line  1663 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(true, "true");  
				break;
			}
			case 109: {
				lexer.NextToken();

#line  1664 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(false, "false"); 
				break;
			}
			case 151: {
				lexer.NextToken();

#line  1665 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(null, "null");  
				break;
			}
			case 25: {
				lexer.NextToken();
				Expr(
#line  1666 "VBNET.ATG" 
out expr);
				Expect(26);

#line  1666 "VBNET.ATG" 
				pexpr = new ParenthesizedExpression(expr); 
				break;
			}
			case 2: case 45: case 49: case 51: case 52: case 53: case 54: case 57: case 74: case 85: case 91: case 94: case 103: case 108: case 113: case 120: case 126: case 130: case 133: case 156: case 162: case 169: case 188: case 197: case 198: case 208: case 209: case 215: {
				Identifier();

#line  1668 "VBNET.ATG" 
				pexpr = new IdentifierExpression(t.val);
				pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;
				
//.........这里部分代码省略.........
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:101,代码来源:Parser.cs


示例9: VisitParenthesizedExpression

		public virtual object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) {
			throw new global::System.NotImplementedException("ParenthesizedExpression");
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:3,代码来源:NotImplementedAstVisitor.cs


示例10: VisitParenthesizedExpression

		public override object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
		{
			return Evaluate(parenthesizedExpression.Expression);
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:4,代码来源:ExpressionEvaluator.cs


示例11: VisitParenthesizedExpression

		public override object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
		{
			base.VisitParenthesizedExpression(parenthesizedExpression, data);
			if (parenthesizedExpression.Expression is CastExpression) {
				ReplaceCurrentNode(parenthesizedExpression.Expression); // remove parenthesis around casts
			} else if (parenthesizedExpression.Parent is CastExpression) {
				ReplaceCurrentNode(parenthesizedExpression.Expression); // remove parenthesis inside casts
			}
			return null;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:10,代码来源:ToVBNetConvertVisitor.cs


示例12: ModifyLambdaForNumerics

		private static INode ModifyLambdaForNumerics(LambdaExpression lambdaExpression,
		                                        ParenthesizedExpression parenthesizedlambdaExpression)
		{
			var castExpression = lambdaExpression.ExpressionBody as CastExpression;
			if (castExpression != null)
			{
				return new CastExpression(new TypeReference("Func", new List<TypeReference>
				{
					new TypeReference("dynamic"),
					castExpression.CastTo
				}), parenthesizedlambdaExpression, CastType.Cast);
			}
			var expression = new LambdaExpression
			{
				ExpressionBody = new CastExpression(new TypeReference("decimal",isKeyword:true), new ParenthesizedExpression(lambdaExpression.ExpressionBody), CastType.Cast),
				Parameters = lambdaExpression.Parameters
			};
			return new CastExpression(new TypeReference("Func<dynamic, decimal>"),
			                          new ParenthesizedExpression(expression), CastType.Cast);

		}
开发者ID:NuvemNine,项目名称:ravendb,代码行数:21,代码来源:TransformDynamicLambdaExpressions.cs


示例13: VisitExpression

			public void VisitExpression (ParenthesizedExpression expression, MethodProperties meth)
			{
				VisitExpression(((ParenthesizedExpression)expression).Expression, meth);
			}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:4,代码来源:ASTVisitor.cs


示例14: VisitParenthesizedExpression

		public override object VisitParenthesizedExpression (ParenthesizedExpression parenthesizedExpression, object data)
		{
			if (parenthesizedExpression == null)
				return null;
			return parenthesizedExpression.Expression.AcceptVisitor (this, data);
		}
开发者ID:Ein,项目名称:monodevelop,代码行数:6,代码来源:ResolveVisitor.cs


示例15: TrackedVisitParenthesizedExpression

 public override object TrackedVisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
 {
     this.Append("(");
     parenthesizedExpression.Expression.AcceptVisitor(this, data);
     this.Append(")");
     return null;
 }
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:7,代码来源:NRefactoryToPythonConverter.cs


示例16: SimpleNonInvocationExpression

	void SimpleNonInvocationExpression(
#line  1730 "VBNET.ATG" 
out Expression pexpr) {

#line  1732 "VBNET.ATG" 
		Expression expr;
		CollectionInitializerExpression cie;
		TypeReference type = null;
		string name = String.Empty;
		Location startLocation = la.Location;
		pexpr = null;
		
		if (StartOf(35)) {
			switch (la.kind) {
			case 3: {
				lexer.NextToken();

#line  1742 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 4: {
				lexer.NextToken();

#line  1743 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 7: {
				lexer.NextToken();

#line  1744 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 6: {
				lexer.NextToken();

#line  1745 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 5: {
				lexer.NextToken();

#line  1746 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 9: {
				lexer.NextToken();

#line  1747 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 8: {
				lexer.NextToken();

#line  1748 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 220: {
				lexer.NextToken();

#line  1750 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(true, "true");  
				break;
			}
			case 124: {
				lexer.NextToken();

#line  1751 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(false, "false"); 
				break;
			}
			case 168: {
				lexer.NextToken();

#line  1752 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(null, "null");  
				break;
			}
			case 37: {
				lexer.NextToken();
				Expr(
#line  1753 "VBNET.ATG" 
out expr);
				Expect(38);

#line  1753 "VBNET.ATG" 
				pexpr = new ParenthesizedExpression(expr); 
				break;
			}
			case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 68: case 69: case 72: case 89: case 100: case 106: case 109: case 118: case 123: case 128: case 135: case 141: case 145: case 148: case 149: case 150: case 173: case 179: case 181: case 187: case 206: case 215: case 216: case 226: case 227: case 233: case 240: {
				Identifier();

#line  1755 "VBNET.ATG" 
				pexpr = new IdentifierExpression(t.val);
//.........这里部分代码省略.........
开发者ID:BooMWax,项目名称:SharpDevelop,代码行数:101,代码来源:Parser.cs


示例17: TestParenthesizedExpression

		public void TestParenthesizedExpression()
		{
			object output = new ParenthesizedExpression(new PrimitiveExpression(5, "5")).AcceptVisitor(new CodeDomVisitor(), null);
			Assert.IsTrue(output is CodePrimitiveExpression);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:5,代码来源:CodeDOMParenthesizedExpressionTest.cs


示例18: VisitParenthesizedExpression

		public override object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
		{
			return CreateResolveResult(parenthesizedExpression.Expression);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:4,代码来源:ResolveVisitor.cs


示例19: VisitParenthesizedExpression

 public virtual object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) {
     throw CreateException(parenthesizedExpression);
 }
开发者ID:hallvar,项目名称:Joddes.CS,代码行数:3,代码来源:JsVisitor.cs


示例20: VisitParenthesizedExpression

		public virtual object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) {
			Debug.Assert((parenthesizedExpression != null));
			Debug.Assert((parenthesizedExpression.Expression != null));
			nodeStack.Push(parenthesizedExpression.Expression);
			parenthesizedExpression.Expression.AcceptVisitor(this, data);
			parenthesizedExpression.Expression = ((Expression)(nodeStack.Pop()));
			return null;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:8,代码来源:AbstractAstTransformer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Ast.PrimitiveExpression类代码示例发布时间:2022-05-26
下一篇:
C# Ast.ParameterDeclarationExpression类代码示例发布时间: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