本文整理汇总了C#中AttributeSection.AddAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeSection.AddAttribute方法的具体用法?C# AttributeSection.AddAttribute怎么用?C# AttributeSection.AddAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeSection
的用法示例。
在下文中一共展示了AttributeSection.AddAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyActionTo
public override ActionResult ApplyActionTo(StringBuilder sb)
{
int startSearch = FieldToAddTo.TextRange.StartOffset;
string text = sb.ToString();
// Put the new Attribute just in front of the property declaration.
int insertionPoint = text.LastIndexOf("\n", startSearch) + 1;
AttributeSection section = new AttributeSection(AttributeToAdd.Controller);
section.AddAttribute(AttributeToAdd);
section.PreceedingBlankLines = -1;
var indentLevel = InsertionHelpers.GetIndentationInFrontOf(text, startSearch);
section.Controller.IndentLevel = indentLevel;
string newText = Helper.StandardizeLineBreaks(section.ToString(), "\n") + "\n";
// Calculate the Attribute's Text Range
// The start index is the insertion point + the number of tabs in front of the attribute, +1 for the \n
AttributeToAdd.TextRange.StartOffset = insertionPoint + indentLevel + 1;
AttributeToAdd.TextRange.EndOffset = AttributeToAdd.TextRange.StartOffset + (newText.Trim()).Length;
sb.Insert(insertionPoint, newText);
FieldToAddTo.AttributeSections.Add(section);
//return new ActionResult(insertionPoint, newText.Length, new[] { AttributeToAdd });
return new ActionResult(AttributeToAdd.TextRange.StartOffset, newText.Length, new[] { AttributeToAdd });
}