/// <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); }