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


C# AttributeSection.AddChild方法代码示例

本文整理汇总了C#中AttributeSection.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeSection.AddChild方法的具体用法?C# AttributeSection.AddChild怎么用?C# AttributeSection.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AttributeSection的用法示例。


在下文中一共展示了AttributeSection.AddChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertAttributeSection

			AttributeSection ConvertAttributeSection (List<Mono.CSharp.Attribute> optAttributes)
			{
				if (optAttributes == null)
					return null;
				AttributeSection result = new AttributeSection ();
				var loc = LocationsBag.GetLocations (optAttributes);
				int pos = 0;
				if (loc != null)
					result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.LBracket);
				
				string target = optAttributes.First ().ExplicitTarget;
				
				if (!string.IsNullOrEmpty (target)) {
					if (loc != null && pos < loc.Count - 1) {
						result.AddChild (Identifier.Create (target, Convert (loc [pos++])), AttributeSection.Roles.Identifier);
					} else {
						result.AddChild (Identifier.Create (target), AttributeSection.Roles.Identifier);
					}
					if (loc != null && pos < loc.Count)
						result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.Colon);
				}
				
				foreach (var attr in GetAttributes (optAttributes)) {
					result.AddChild (attr, AttributeSection.AttributeRole);
				}
				// optional comma
				if (loc != null && pos < loc.Count - 1 && !loc [pos].Equals (loc [pos + 1]))
					result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.Comma);
				if (loc != null && pos < loc.Count)
					result.AddChild (new CSharpTokenNode (Convert (loc [pos++]), 1), AttributeSection.Roles.RBracket);
				return result;
			}
开发者ID:N3X15,项目名称:ILSpy,代码行数:32,代码来源:CSharpParser.cs

示例2: ConvertAttributeSection

			AttributeSection ConvertAttributeSection(IEnumerable<Mono.CSharp.Attribute> optAttributes)
			{
				if (optAttributes == null)
					return null;
				var result = new AttributeSection();
				var loc = LocationsBag.GetLocations(optAttributes);
				int pos = 0;
				if (loc != null)
					result.AddChild(new CSharpTokenNode(Convert(loc [pos++]), Roles.LBracket), Roles.LBracket);
				var first = optAttributes.FirstOrDefault();
				string target = first != null ? first.ExplicitTarget : null;
				
				if (!string.IsNullOrEmpty(target)) {
					if (loc != null && pos < loc.Count - 1) {
						result.AddChild(Identifier.Create(target, Convert(loc [pos++])), Roles.Identifier);
					} else {
						result.AddChild(Identifier.Create(target), Roles.Identifier);
					}
					if (loc != null && pos < loc.Count)
						result.AddChild(new CSharpTokenNode(Convert(loc [pos++]), Roles.Colon), Roles.Colon);
				}

				int attributeCount = 0;
				foreach (var attr in GetAttributes (optAttributes)) {
					result.AddChild(attr, Roles.Attribute);
					if (loc != null && pos + 1 < loc.Count)
						result.AddChild(new CSharpTokenNode(Convert(loc [pos++]), Roles.Comma), Roles.Comma);

					attributeCount++;
				}
				if (attributeCount == 0)
					return null;
				// Left and right bracket + commas between the attributes
				int locCount = 2 + attributeCount - 1;
				// optional comma
				if (loc != null && pos < loc.Count - 1 && loc.Count == locCount + 1)
					result.AddChild(new CSharpTokenNode(Convert(loc [pos++]), Roles.Comma), Roles.Comma);
				if (loc != null && pos < loc.Count)
					result.AddChild(new CSharpTokenNode(Convert(loc [pos++]), Roles.RBracket), Roles.RBracket);
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:41,代码来源:CSharpParser.cs

示例3: ConvertAttributeSection

			AttributeSection ConvertAttributeSection (List<Mono.CSharp.Attribute> optAttributes)
			{
				if (optAttributes == null)
					return null;
				
				AttributeSection result = new AttributeSection ();
				var loc = LocationsBag.GetLocations (optAttributes);
				if (loc != null)
					result.AddChild (new CSharpTokenNode (Convert (loc [0]), 1), AttributeSection.Roles.LBracket);
				
				result.AttributeTarget = optAttributes.First ().ExplicitTarget;
				foreach (var attr in GetAttributes (optAttributes)) {
					result.AddChild (attr, AttributeSection.AttributeRole);
				}
				
				if (loc != null)
					result.AddChild (new CSharpTokenNode (Convert (loc [1]), 1), AttributeSection.Roles.RBracket);
				return result;
			}
开发者ID:aleksandersumowski,项目名称:monodevelop,代码行数:19,代码来源:CSharpParser.cs


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