本文整理汇总了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;
}
示例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;
}
示例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;
}