Example #1
0
 /// <summary>
 /// Ensures that the book is in a state such that our assumptions about ordering, etc. hold true.
 /// </summary>
 /// <param name="book">The book.</param>
 private static void normalize(Book book)
 {
     book.Chapters.Sort(Util.Helpers.ChapterSort);
     for (int i = 0; i < book.Chapters.Count; i++)
     {
         Chapter c = book.Chapters[i];
         c.Ordering = i;
         c.Posts.Sort(Util.Helpers.PostSort);
         for (int j = 0; j < c.Posts.Count; j++)
         {
             c.Posts[j].Ordering = j;
         }
     }
 }
Example #2
0
 /// <summary>
 /// Adds <c>newChapter</c> to the given <see cref="Book"/> immediately
 /// following the <c>precedingChapter</c>.
 /// </summary>
 /// <param name="newChapter">The chapter to add.</param>
 /// <param name="precedingChapter">The chapter immediately before the
 /// insertion point, or <c>null</c> if adding to the beginning.</param>
 public AddChapterAction(Book book, Chapter newChapter, Chapter precedingChapter)
 {
     this.book = book;
     this.newChapter = newChapter;
     this.precedingChapter = precedingChapter;
 }
 public void Save(Book book, Stream stream)
 {
     new XmlSerializer(typeof(Book)).Serialize(stream, book);
 }
Example #4
0
 public MoveChapterAction(Chapter source, Book book, Chapter target = null)
 {
     this.book = book;
     this.source = source;
     this.target = target;
 }