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


C# ArrayInitializerExpression类代码示例

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


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


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