本文整理汇总了C#中CsDocument.InsertBefore方法的典型用法代码示例。如果您正苦于以下问题:C# CsDocument.InsertBefore方法的具体用法?C# CsDocument.InsertBefore怎么用?C# CsDocument.InsertBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsDocument
的用法示例。
在下文中一共展示了CsDocument.InsertBefore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFileHeader
/// <summary>
/// Adds a file header at the top of the given document.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="copyright">The required copyright text.</param>
/// <param name="companyName">The required company name text.</param>
private void AddFileHeader(CsDocument document, string copyright, string companyName)
{
Param.AssertNotNull(document, "document");
Param.Ignore(copyright);
Param.Ignore(companyName);
List<SingleLineComment> fileHeaderElements = new List<SingleLineComment>();
fileHeaderElements.Add(document.CreateSingleLineComment("//-----------------------------------------------------------------------"));
string closingTag = ">";
if (copyright == null)
{
closingTag = " />";
}
if (!string.IsNullOrWhiteSpace(companyName))
{
fileHeaderElements.Add(document.CreateSingleLineComment(string.Format("// <copyright file=\"{0}\" company=\"{1}\"{2}", document.Name, companyName, closingTag)));
}
else
{
fileHeaderElements.Add(document.CreateSingleLineComment(string.Format("// <copyright file=\"{0}\"{1}", document.Name, closingTag)));
}
if (copyright != null)
{
fileHeaderElements.Add(document.CreateSingleLineComment(string.Format("// {0}", copyright)));
fileHeaderElements.Add(document.CreateSingleLineComment("// </copyright>"));
}
fileHeaderElements.Add(document.CreateSingleLineComment("//-----------------------------------------------------------------------"));
FileHeader fileHeader = document.CreateFileHeader(fileHeaderElements);
document.InsertBefore(fileHeader, document.Children.First);
document.InsertAfter(document.CreateEndOfLine(), fileHeader);
}