/// <summary> /// Adds the given section as a subsection to the current section. /// </summary> /// <param name="sub"></param> /// <exception cref="System.ArgumentNullException">Thrown when the given subsection is null.</exception> /// <exception cref="System.ArgumentException">Thrown when the given section is identical to the current one -or- the given section is contained within the hierarcy of the current one -or- the current section is contained within the hierarchy of the given one -or- the current section already contains a subsection with the title of the given section.</exception> public void AddSubsection(Section sub) { if (sub == null) { throw new ArgumentNullException("sub"); } if (sub == this) { throw new ArgumentException("Cannot add the current section as subsection to itself."); } if (ManualSections.Check(sub, this)) { throw new ArgumentException("The current section is already found within the subsection hierarchy of the given section."); } if (ManualSections.Check(this, sub)) { throw new ArgumentException("The given section is already found within the subsection hierarchy of the current section."); } if (subs.Where(s => s.title == sub.title).Any()) { throw new ArgumentException("There already is a subsection with that title."); } CheckSeal(); subs.Add(sub); }
/// <summary> /// Formats the given manual and outputs it in the result. /// </summary> /// <param name="context"></param> /// <param name="m"></param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">Thrown when the given context or manual are null.</exception> /// <exception cref="System.ArgumentException">Thrown when the given manual has a null title.</exception> public virtual EvaluationResult Display(EvaluationContext context, Manual m) { if (context == null) { throw new ArgumentNullException("context"); } if (m == null) { throw new ArgumentNullException("m"); } if (m.Title == null) { throw new ArgumentException("The given manual has a null title."); } StringBuilder b = new StringBuilder(); b.AppendLine("Title:"); b.Append('\t'); b.AppendLine(m.Title); b.AppendLine(); if (m.Abstract != null) { b.AppendLine("Abstract:"); b.Append('\t'); b.AppendLine(m.Abstract); b.AppendLine(); } var sectionIndexes = new Dictionary <Section, string>(); b.AppendLine("Index:"); int i = 0; foreach (var s in m.Sections) { ManualSections.indexSection(b, s, ++i, "\t", sectionIndexes, SectionTitlesSeparator, SectionIndexesSeparator); } b.AppendLine(); b.AppendLine(LargeSeparator); foreach (var s in m.Sections) { displaySection(b, s, sectionIndexes); } return(new EvaluationResult(CommonStatusCodes.Success, null, b.ToString())); }
/// <summary> /// Adds the given section to the manual. /// </summary> /// <param name="sub"></param> /// <exception cref="System.ArgumentNullException">Thrown when the given section is null.</exception> /// <exception cref="System.ArgumentException">Thrown when the given section is contained within the hierarcy of the manual -or- the manual already contains a section with the title of the given section.</exception> public void AddSection(Section sub) { if (sub == null) { throw new ArgumentNullException("sub"); } if (ManualSections.Check(this.subs, sub)) { throw new ArgumentException("The given section is already found within the hierarchy of the manual."); } if (subs.Where(s => s.Title == sub.Title).Any()) { throw new ArgumentException("There already is a section with that title."); } CheckSeal(); subs.Add(sub); }