Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }