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

C# ArrayInitializerExpression类代码示例

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

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



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

示例1: VisitArrayInitializerExpression

        public override void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression)
        {
            if (DoWrap(policy.ArrayInitializerWrapping, arrayInitializerExpression.RBraceToken, arrayInitializerExpression.Elements.Count)) {
                FixOpenBrace(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.LBraceToken);
                curIndent.Push(IndentType.Block);
                foreach (var init in arrayInitializerExpression.Elements) {
                    FixStatementIndentation(init.StartLocation);
                    init.AcceptVisitor(this);
                }
                curIndent.Pop();
                FixClosingBrace(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.RBraceToken);
            } else if (policy.ArrayInitializerWrapping == Wrapping.DoNotWrap) {
                ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.LBraceToken);
                ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.RBraceToken);
                foreach (var init in arrayInitializerExpression.Elements) {
                    ForceSpacesBeforeRemoveNewLines(init);
                    init.AcceptVisitor(this);
                }
            } else {
                var lBrace = arrayInitializerExpression.LBraceToken;
                var rBrace = arrayInitializerExpression.RBraceToken;

                foreach (var child in arrayInitializerExpression.Children) {
                    if (child.Role == Roles.LBrace) {
                        if (lBrace.StartLocation.Line == rBrace.StartLocation.Line && policy.AllowOneLinedArrayInitialziers) {
                            ForceSpaceBefore(child, true);
                            ForceSpacesAfter(child, true);
                        } else {
                            FixOpenBrace(policy.ArrayInitializerBraceStyle, child);
                        }
                        curIndent.Push(IndentType.Block);
                        continue;
                    }
                    if (child.Role == Roles.RBrace) {
                        curIndent.Pop();
                        if (lBrace.StartLocation.Line == rBrace.StartLocation.Line && policy.AllowOneLinedArrayInitialziers) {
                            ForceSpaceBefore(child, true);

                        } else {
                            FixClosingBrace(policy.ArrayInitializerBraceStyle, child);
                        }
                        continue;
                    }
                    if (child.Role == Roles.Expression) {
                        if (child.PrevSibling != null) {
                            if (child.PrevSibling.Role == Roles.NewLine)
                                FixIndentation(child);
                            if (child.PrevSibling.Role == Roles.Comma)
                                ForceSpaceBefore(child, true);
                        }
                        child.AcceptVisitor(this);
                        if (child.NextSibling != null && child.NextSibling.Role == Roles.Comma)
                            ForceSpacesAfter(child, false);
                        continue;
                    }

                    child.AcceptVisitor(this);
                }
            }
        }
开发者ID:porcus,项目名称:NRefactory,代码行数:60,代码来源:FormattingVisitor_Expressions.cs


示例2: VisitArrayInitializerExpression

 public virtual void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(arrayInitializerExpression);
     }
 }
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs


示例3: VisitArrayInitializerExpression

            public override object VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, object data)
            {
                if(arrayInitializerExpression.Parent is ArrayCreateExpression)
                {
                    UnlockWith(arrayInitializerExpression);
                }

                return base.VisitArrayInitializerExpression(arrayInitializerExpression, data);
            }
开发者ID:vlad2135,项目名称:strokes,代码行数:9,代码来源:DeclareInitArrayAchievement.cs


示例4: VisitArrayInitializerExpression

			public override void VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression)
			{
				base.VisitArrayInitializerExpression (arrayInitializerExpression);

				if (arrayInitializerExpression.IsSingleElement)
					return;

				var commaToken = arrayInitializerExpression.RBraceToken.PrevSibling as CSharpTokenNode;
				if (commaToken == null || commaToken.GetText () != ",")
					return;
				AddIssue (commaToken, ctx.TranslateString ("Remove redundant comma in array initializer"),
					script => script.Remove (commaToken));
			}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:13,代码来源:RedundantArrayInitializerCommaIssue.cs


示例5: VisitArrayInitializerExpression

 public override void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression)
 {
     if (DoWrap(policy.ArrayInitializerWrapping, arrayInitializerExpression.RBraceToken, arrayInitializerExpression.Elements.Count)) {
         FixOpenBrace(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.LBraceToken);
         curIndent.Push(IndentType.Block);
         foreach (var init in arrayInitializerExpression.Elements) {
             FixStatementIndentation(init.StartLocation);
             init.AcceptVisitor(this);
         }
         curIndent.Pop();
         FixClosingBrace(policy.ArrayInitializerBraceStyle, arrayInitializerExpression.RBraceToken);
     } else if (policy.ArrayInitializerWrapping == Wrapping.DoNotWrap) {
         ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.LBraceToken);
         ForceSpacesBeforeRemoveNewLines(arrayInitializerExpression.RBraceToken);
         foreach (var init in arrayInitializerExpression.Elements) {
             ForceSpacesBeforeRemoveNewLines(init);
             init.AcceptVisitor(this);
         }
     } else {
         base.VisitArrayInitializerExpression(arrayInitializerExpression);
     }
 }
开发者ID:CSRedRat,项目名称:NRefactory,代码行数:22,代码来源:FormattingVisitor_Expressions.cs


示例6: VisitArrayInitializerExpression

			public override void VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression)
			{
				base.VisitArrayInitializerExpression (arrayInitializerExpression);

				if (arrayInitializerExpression.IsSingleElement)
					return;

				var commaToken = arrayInitializerExpression.RBraceToken.PrevSibling as CSharpTokenNode;
				if (commaToken == null || commaToken.GetText () != ",")
					return;
				string initializerType;
				if (arrayInitializerExpression.Parent is ObjectCreateExpression) {
					if (arrayInitializerExpression.Elements.FirstOrNullObject () is NamedExpression) {
						initializerType = "object";
					} else {
						initializerType = "collection";
					}
				} else {
					initializerType = "array";
				}
				AddIssue (commaToken, 
					ctx.TranslateString (string.Format("Remove redundant comma in {0} initializer", initializerType)),
					script => script.Remove (commaToken));
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:24,代码来源:RedundantArrayInitializerCommaIssue.cs


示例7: VisitArrayInitializerExpression

 public override void VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression)
 {
     new ArrayInitializerBlock(this, arrayInitializerExpression).Emit();
 }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:4,代码来源:Emitter.Visitor.cs


示例8: InsertImplicitInitializersForPath

		bool InsertImplicitInitializersForPath(AccessPath path)
		{
			if (accessPaths.ContainsKey(path))
				return true;

			if (path.MemberPath.Count == 0)
				return false;
			var parentPath = path.GetParentPath();
			var success = InsertImplicitInitializersForPath(parentPath);
			if (!success)
				return false;

			var parentInitializer = accessPaths [parentPath];
			var initializer = new ArrayInitializerExpression();
			var namedExpression = new NamedExpression(path.MemberPath [path.MemberPath.Count - 1].Name, initializer);
			AddToInitializer(parentInitializer, namedExpression);
			accessPaths [path] = initializer;
			return true;
		}
开发者ID:FloodProject,项目名称:ICSharpCode.NRefactory,代码行数:19,代码来源:StatementsToInitializerConverter.cs


示例9: Visit

 public override object Visit(ArrayInitializerExpression arrayInitializerExpression, object data)
 {
     // no calls allowed !!!
     return null;
 }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:5,代码来源:TypeVisitor.cs


示例10: VisitArrayInitializerExpression

		public virtual void VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression)
		{
			VisitChildren (arrayInitializerExpression);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs


示例11: Visit

			public override object Visit(ArrayCreation arrayCreationExpression)
			{
				var result = new ArrayCreateExpression();
				
				var location = LocationsBag.GetLocations(arrayCreationExpression);
				result.AddChild(new CSharpTokenNode(Convert(arrayCreationExpression.Location), ArrayCreateExpression.NewKeywordRole), ArrayCreateExpression.NewKeywordRole);
				if (arrayCreationExpression.TypeExpression != null)
					result.AddChild(ConvertToType(arrayCreationExpression.TypeExpression), Roles.Type);
				
				var next = arrayCreationExpression.Rank;
				if (arrayCreationExpression.Arguments != null) {
					// skip first array rank.
					next = next.Next;
					
					if (location != null)
						result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LBracket), Roles.LBracket);
					
					var commaLocations = LocationsBag.GetLocations(arrayCreationExpression.Arguments);
					for (int i = 0; i < arrayCreationExpression.Arguments.Count; i++) {
						var arg = arrayCreationExpression.Arguments [i];
						if (arg != null)
							result.AddChild((Expression)arg.Accept(this), Roles.Argument);
						if (commaLocations != null && i < commaLocations.Count)
							result.AddChild(new CSharpTokenNode(Convert(commaLocations [i]), Roles.Comma), Roles.Comma);
					}
					if (location != null && location.Count > 1)
						result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RBracket), Roles.RBracket);
					
				}
				
				while (next != null) {
					var spec = new ArraySpecifier(next.Dimension);
					var loc = LocationsBag.GetLocations(next);
					spec.AddChild(new CSharpTokenNode(Convert(next.Location), Roles.LBracket), Roles.LBracket);
					result.AddChild(spec, ArrayCreateExpression.AdditionalArraySpecifierRole);
					if (loc != null)
						result.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.RBracket), Roles.RBracket);
					next = next.Next;
				}
				
				if (arrayCreationExpression.Initializers != null) {
					var initLocation = LocationsBag.GetLocations(arrayCreationExpression.Initializers);
					var initializer = new ArrayInitializerExpression();
					
					initializer.AddChild(new CSharpTokenNode(Convert(arrayCreationExpression.Initializers.Location), Roles.LBrace), Roles.LBrace);
					var commaLocations = LocationsBag.GetLocations(arrayCreationExpression.Initializers.Elements);
					for (int i = 0; i < arrayCreationExpression.Initializers.Count; i++) {
						var init = arrayCreationExpression.Initializers [i];
						if (init == null)
							continue;
						initializer.AddChild((Expression)init.Accept(this), Roles.Expression);
						if (commaLocations != null && i < commaLocations.Count) {
							initializer.AddChild(new CSharpTokenNode(Convert(commaLocations [i]), Roles.Comma), Roles.Comma);
						}
					}
					if (initLocation != null) {
						if (initLocation.Count == 2) // optional comma
							initializer.AddChild(new CSharpTokenNode(Convert(initLocation [0]), Roles.Comma), Roles.Comma);
						initializer.AddChild(new CSharpTokenNode(Convert(initLocation [initLocation.Count - 1]), Roles.RBrace), Roles.RBrace);
					}
					result.AddChild(initializer, ArrayCreateExpression.InitializerRole);
				}
				
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:65,代码来源:CSharpParser.cs


示例12: ConvertCollectionOrObjectInitializers

			ArrayInitializerExpression ConvertCollectionOrObjectInitializers(CollectionOrObjectInitializers minit)
			{
				if (minit == null)
					return null;
				var init = new ArrayInitializerExpression();
				AddConvertCollectionOrObjectInitializers(init, minit);
				return init;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:8,代码来源:CSharpParser.cs


示例13: ConvertElementInit

 ArrayInitializerExpression ConvertElementInit(Expression elementsArray)
 {
     IList<Expression> elements = ConvertExpressionsArray(elementsArray);
     if (elements != null) {
         return new ArrayInitializerExpression(elements);
     }
     Match m = elementInitArrayPattern.Match(elementsArray);
     if (!m.Success)
         return null;
     ArrayInitializerExpression result = new ArrayInitializerExpression();
     foreach (var elementInit in m.Get<Expression>("addArgumentsArrays")) {
         IList<Expression> arguments = ConvertExpressionsArray(elementInit);
         if (arguments == null)
             return null;
         result.Elements.Add(new ArrayInitializerExpression(arguments));
     }
     return result;
 }
开发者ID:ropean,项目名称:Usable,代码行数:18,代码来源:ExpressionTreeConverter.cs


示例14: ConvertCollectionOrObjectInitializers

			ArrayInitializerExpression ConvertCollectionOrObjectInitializers (CollectionOrObjectInitializers minit)
			{
				if (minit == null)
					return null;
				var init = new ArrayInitializerExpression ();
				var braceLocs = LocationsBag.GetLocations (minit);
				if (braceLocs != null)
					init.AddChild (new CSharpTokenNode (Convert (braceLocs[0]), 1), ArrayInitializerExpression.Roles.LBrace);
				AddConvertCollectionOrObjectInitializers (init, minit);
				if (braceLocs != null)
					init.AddChild (new CSharpTokenNode (Convert (braceLocs[1]), 1), ArrayInitializerExpression.Roles.RBrace);
				return init;
			}
开发者ID:aleksandersumowski,项目名称:monodevelop,代码行数:13,代码来源:CSharpParser.cs


示例15: VisitArrayInitializerExpression

 public abstract StringBuilder VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, int data);
开发者ID:hach-que,项目名称:SLSharp,代码行数:1,代码来源:VisitorBase.Abstract.cs


示例16: Visit

			public override object Visit (ArrayInitializer arrayInitializer)
			{
				var result = new ArrayInitializerExpression ();
				var location = LocationsBag.GetLocations (arrayInitializer);
				var commaLocations = LocationsBag.GetLocations (arrayInitializer.Elements);
				for (int i = 0; i < arrayInitializer.Count; i++) {
					result.AddChild((Expression)arrayInitializer[i].Accept(this), ArrayInitializerExpression.Roles.Expression);
				}
				
				return result;
			}
开发者ID:madkat,项目名称:NRefactory,代码行数:11,代码来源:CSharpParser.cs


示例17: TransformByteCode

		AstNode TransformByteCode(ILExpression byteCode)
		{
			object operand = byteCode.Operand;
			AstType operandAsTypeRef = AstBuilder.ConvertType(operand as ITypeDefOrRef);

			List<Ast.Expression> args = new List<Expression>();
			foreach(ILExpression arg in byteCode.Arguments) {
				args.Add((Ast.Expression)TransformExpression(arg));
			}
			Ast.Expression arg1 = args.Count >= 1 ? args[0] : null;
			Ast.Expression arg2 = args.Count >= 2 ? args[1] : null;
			Ast.Expression arg3 = args.Count >= 3 ? args[2] : null;
			
			switch (byteCode.Code) {
					#region Arithmetic
				case ILCode.Add:
				case ILCode.Add_Ovf:
				case ILCode.Add_Ovf_Un:
					{
						BinaryOperatorExpression boe;
						if (byteCode.InferredType is PtrSig) {
							boe = new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Add, arg2);
							if (byteCode.Arguments[0].ExpectedType is PtrSig ||
								byteCode.Arguments[1].ExpectedType is PtrSig) {
								boe.AddAnnotation(IntroduceUnsafeModifier.PointerArithmeticAnnotation);
							}
						} else {
							boe = new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Add, arg2);
						}
						boe.AddAnnotation(byteCode.Code == ILCode.Add ? AddCheckedBlocks.UncheckedAnnotation : AddCheckedBlocks.CheckedAnnotation);
						return boe;
					}
				case ILCode.Sub:
				case ILCode.Sub_Ovf:
				case ILCode.Sub_Ovf_Un:
					{
						BinaryOperatorExpression boe;
						if (byteCode.InferredType is PtrSig) {
							boe = new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Subtract, arg2);
							if (byteCode.Arguments[0].ExpectedType is PtrSig) {
								boe.WithAnnotation(IntroduceUnsafeModifier.PointerArithmeticAnnotation);
							}
						} else {
							boe = new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Subtract, arg2);
						}
						boe.AddAnnotation(byteCode.Code == ILCode.Sub ? AddCheckedBlocks.UncheckedAnnotation : AddCheckedBlocks.CheckedAnnotation);
						return boe;
					}
					case ILCode.Div:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Divide, arg2);
					case ILCode.Div_Un:     return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Divide, arg2);
					case ILCode.Mul:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Multiply, arg2).WithAnnotation(AddCheckedBlocks.UncheckedAnnotation);
					case ILCode.Mul_Ovf:    return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Multiply, arg2).WithAnnotation(AddCheckedBlocks.CheckedAnnotation);
					case ILCode.Mul_Ovf_Un: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Multiply, arg2).WithAnnotation(AddCheckedBlocks.CheckedAnnotation);
					case ILCode.Rem:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Modulus, arg2);
					case ILCode.Rem_Un:     return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Modulus, arg2);
					case ILCode.And:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.BitwiseAnd, arg2);
					case ILCode.Or:         return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.BitwiseOr, arg2);
					case ILCode.Xor:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.ExclusiveOr, arg2);
					case ILCode.Shl:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.ShiftLeft, arg2);
					case ILCode.Shr:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.ShiftRight, arg2);
					case ILCode.Shr_Un:     return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.ShiftRight, arg2);
					case ILCode.Neg:        return new Ast.UnaryOperatorExpression(UnaryOperatorType.Minus, arg1).WithAnnotation(AddCheckedBlocks.UncheckedAnnotation);
					case ILCode.Not:        return new Ast.UnaryOperatorExpression(UnaryOperatorType.BitNot, arg1);
				case ILCode.PostIncrement:
				case ILCode.PostIncrement_Ovf:
				case ILCode.PostIncrement_Ovf_Un:
					{
						if (arg1 is DirectionExpression)
							arg1 = ((DirectionExpression)arg1).Expression.Detach();
						var uoe = new Ast.UnaryOperatorExpression(
							(int)byteCode.Operand > 0 ? UnaryOperatorType.PostIncrement : UnaryOperatorType.PostDecrement, arg1);
						uoe.AddAnnotation((byteCode.Code == ILCode.PostIncrement) ? AddCheckedBlocks.UncheckedAnnotation : AddCheckedBlocks.CheckedAnnotation);
						return uoe;
					}
					#endregion
					#region Arrays
					case ILCode.Newarr: {
						var ace = new Ast.ArrayCreateExpression();
						ace.Type = operandAsTypeRef;
						ComposedType ct = operandAsTypeRef as ComposedType;
						if (ct != null) {
							// change "new (int[,])[10] to new int[10][,]"
							ct.ArraySpecifiers.MoveTo(ace.AdditionalArraySpecifiers);
						}
						if (byteCode.Code == ILCode.InitArray) {
							ace.Initializer = new ArrayInitializerExpression();
							ace.Initializer.Elements.AddRange(args);
						} else {
							ace.Arguments.Add(arg1);
						}
						return ace;
					}
					case ILCode.InitArray: {
						var ace = new Ast.ArrayCreateExpression();
						ace.Type = operandAsTypeRef;
						ComposedType ct = operandAsTypeRef as ComposedType;
						if (ct != null)
						{
							// change "new (int[,])[10] to new int[10][,]"
							ct.ArraySpecifiers.MoveTo(ace.AdditionalArraySpecifiers);
//.........这里部分代码省略.........
开发者ID:nakijun,项目名称:dnSpy,代码行数:101,代码来源:AstMethodBodyBuilder.cs


示例18: ArrayInitializerBlock

 public ArrayInitializerBlock(IEmitter emitter, ArrayInitializerExpression arrayInitializerExpression)
     : base(emitter, arrayInitializerExpression)
 {
     this.Emitter = emitter;
     this.ArrayInitializerExpression = arrayInitializerExpression;
 }
开发者ID:txdv,项目名称:Builder,代码行数:6,代码来源:ArrayInitializerBlock.cs


示例19: Visit

			public override object Visit (ArrayInitializer arrayInitializer)
			{
				var result = new ArrayInitializerExpression ();
				var location = LocationsBag.GetLocations (arrayInitializer);
				result.AddChild (new CSharpTokenNode (Convert (arrayInitializer.Location), "[".Length), ArrayInitializerExpression.Roles.LBracket);
				var commaLocations = LocationsBag.GetLocations (arrayInitializer.Elements);
				for (int i = 0; i < arrayInitializer.Count; i++) {
					result.AddChild ((AstNode)arrayInitializer[i].Accept (this), ArrayInitializerExpression.Roles.Initializer);
					if (commaLocations != null && i < commaLocations.Count)
						result.AddChild (new CSharpTokenNode (Convert (commaLocations[i]), ",".Length), ArrayInitializerExpression.Roles.Comma);
				}
				
				if (location != null) {
					if (location.Count == 2) // optional comma
						result.AddChild (new CSharpTokenNode (Convert (location[1]), ",".Length), ArrayInitializerExpression.Roles.Comma);
					result.AddChild (new CSharpTokenNode (Convert (location[location.Count - 1]), "]".Length), ArrayInitializerExpression.Roles.RBracket);
				}
				return result;
			}
开发者ID:tech-uday-mca,项目名称:monodevelop,代码行数:19,代码来源:CSharpParser.cs


示例20: AddConvertCollectionOrObjectInitializers

			void AddConvertCollectionOrObjectInitializers (Expression init, CollectionOrObjectInitializers minit)
			{
				var initLoc = LocationsBag.GetLocations (minit);
				var commaLoc = LocationsBag.GetLocations (minit.Initializers);
				int curComma = 0;
				if (initLoc != null)
					init.AddChild (new CSharpTokenNode (Convert (initLoc [0]), 1), ArrayInitializerExpression.Roles.LBrace);
				foreach (var expr in minit.Initializers) {
					var collectionInit = expr as CollectionElementInitializer;
					if (collectionInit != null) {
						var parent = new ArrayInitializerExpression ();
						
						var braceLocs = LocationsBag.GetLocations (expr);
						if (braceLocs != null)
							parent.AddChild (new CSharpTokenNode (Convert (braceLocs [0]), 1), ArrayInitializerExpression.Roles.LBrace);
						
						for (int i = 0; i < collectionInit.Arguments.Count; i++) {
							var arg = collectionInit.Arguments [i] as CollectionElementInitializer.ElementInitializerArgument;
							if (arg == null)
								continue;
							parent.AddChild ((ICSharpCode.NRefactory.CSharp.Expression)arg.Expr.Accept (this), ArrayInitializerExpression.Roles.Expression);
						}
						
						if (braceLocs != null)
							parent.AddChild (new CSharpTokenNode (Convert (braceLocs [1]), 1), ArrayInitializerExpression.Roles.RBrace);
							
						init.AddChild (parent, ArrayInitializerExpression.Roles.Expression);
					} else {
						var eleInit = expr as ElementInitializer;
						if (eleInit != null) {
							var nexpr = new NamedExpression ();
							nexpr.AddChild (Identifier.Create (eleInit.Name, Convert (eleInit.Location)), NamedArgumentExpression.Roles.Identifier);
							var assignLoc = LocationsBag.GetLocations (eleInit);
							if (assignLoc != null)
								nexpr.AddChild (new CSharpTokenNode (Convert (assignLoc [0]), 1), NamedArgumentExpression.Roles.Assign);
							if (eleInit.Source != null) {
								if (eleInit.Source is CollectionOrObjectInitializers) {
									var arrInit = new ArrayInitializerExpression ();
									AddConvertCollectionOrObjectInitializers (arrInit, eleInit.Source as CollectionOrObjectInitializers);
									nexpr.AddChild (arrInit, NamedArgumentExpression.Roles.Expression);
								} else {
									nexpr.AddChild ((Expression)eleInit.Source.Accept (this), NamedArgumentExpression.Roles.Expression);
								}
							}
							
							init.AddChild (nexpr, ArrayInitializerExpression.Roles.Expression);
						}
					}
					if (commaLoc != null && curComma < commaLoc.Count)
						init.AddChild (new CSharpTokenNode (Convert (commaLoc [curComma++]), 1), ArrayInitializerExpression.Roles.Comma);
					
				}
				if (initLoc != null) {
					if (initLoc.Count == 3) // optional comma
						init.AddChild (new CSharpTokenNode (Convert (initLoc [1]), 1), ArrayInitializerExpression.Roles.Comma);
					init.AddChild (new CSharpTokenNode (Convert (initLoc [initLoc.Count - 1]), 1), ArrayInitializerExpression.Roles.RBrace);
				}
			}
开发者ID:N3X15,项目名称:ILSpy,代码行数:58,代码来源:CSharpParser.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ArrayList类代码示例发布时间:2022-05-24
下一篇:
C# ArrayInitializer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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