Пример #1
0
        internal static CommentLine CreateNew(Entry entry, CommentLine.Kinds kind, int?index, bool isContinuation, IO.TextLine addRelativeTo, bool addRelativeToBefore, string text)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }
            if (addRelativeTo == null)
            {
                throw new ArgumentNullException("addRelativeTo");
            }
            int insertAt = entry.File.TextFile.Lines.IndexOf(addRelativeTo);

            if (insertAt < 0)
            {
                throw new ArgumentOutOfRangeException("addRelativeTo");
            }
            if (!addRelativeToBefore)
            {
                insertAt++;
            }
            IO.TextLine textLine = new IO.TextLine(BuildTextFileData(kind, index, isContinuation, text));
            entry.File.TextFile.Lines.Insert(insertAt, textLine);
            CommentLine result;

            if (index.HasValue)
            {
                result = new IndexedCommentLine(entry.File, textLine, isContinuation, kind, text, index.Value);
            }
            else
            {
                result = new CommentLine(entry.File, textLine, isContinuation, kind, text);
            }
            entry.LineAdded(result);
            return(result);
        }
Пример #2
0
 internal static CommentLine CreateNew(Entry entry, CommentLine.Kinds kind, int? index, bool isContinuation, IO.TextLine addRelativeTo, bool addRelativeToBefore, string text)
 {
     if (entry == null)
         throw new ArgumentNullException("entry");
     if (addRelativeTo == null)
         throw new ArgumentNullException("addRelativeTo");
     int insertAt = entry.File.TextFile.Lines.IndexOf(addRelativeTo);
     if (insertAt < 0)
         throw new ArgumentOutOfRangeException("addRelativeTo");
     if (!addRelativeToBefore)
         insertAt++;
     IO.TextLine textLine = new IO.TextLine(BuildTextFileData(kind, index, isContinuation, text));
     entry.File.TextFile.Lines.Insert(insertAt, textLine);
     CommentLine result;
     if (index.HasValue)
         result = new IndexedCommentLine(entry.File, textLine, isContinuation, kind, text, index.Value);
     else
         result = new CommentLine(entry.File, textLine, isContinuation, kind, text);
     entry.LineAdded(result);
     return result;
 }