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


C# Ast.ParenthesizedExpression类代码示例

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


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


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