Click here to Skip to main content
15,895,813 members
Articles / Operating Systems / Windows

Sandcastle Help File Builder

Rate me:
Please Sign up or sign in to vote.
4.93/5 (131 votes)
17 May 2007Ms-PL45 min read 1M   5.3K   291  
A GUI for creating projects to build help files with Sandcastle and a console mode tool to build them as well.
//=============================================================================
// System  : Sandcastle Help File Builder Utilities
// File    : NamespaceSummaryItemCollection.cs
// Author  : Eric Woodruff
// Updated : 09/29/2006
// Note    : Copyright 2006, Eric Woodruff, All rights reserved
// Compiler: Microsoft Visual C#
//
// This file contains a collection class used to hold the namespace summary
// item information.
//
// This code may be used in compiled form in any way you desire.  This file
// may be redistributed unmodified by any means PROVIDING it is not sold for
// profit without the author's written consent, and providing that this notice
// and the author's name and all copyright notices remain intact.
//
// This code is provided "as is" with no warranty either express or implied.
// The author accepts no liability for any damage or loss of business that
// this product may cause.
//
// Version     Date     Who  Comments
// ============================================================================
// 1.2.0.0  09/04/2006  EFW  Created the code
//=============================================================================

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.IO;
using System.Text;
using System.Xml;

using SandcastleBuilder.Utils.Design;

namespace SandcastleBuilder.Utils
{
    /// <summary>
    /// This collection class is used to hold the namespace summary items
    /// for a project.
    /// </summary>
    /// <remarks>Namespaces that appear in the assemblies but not in this
    /// list are documented by default and will appear without a namespace
    /// summary.</remarks>
    public class NamespaceSummaryItemCollection : BindingList<NamespaceSummaryItem>
    {
        #region Internal methods
        //=====================================================================
        // Internal methods

        /// <summary>
        /// This is used to save the namespace summary item list to the project
        /// file.
        /// </summary>
        /// <param name="xw">The XML text writer to which the information
        /// is written.</param>
        internal void WriteXml(XmlTextWriter xw)
        {
            if(base.Count > 0)
            {
                xw.WriteStartElement("namespaceSummaries");

                foreach(NamespaceSummaryItem nsi in this)
                    nsi.WriteXml(xw);

                xw.WriteEndElement();
            }
        }

        /// <summary>
        /// This is used to load the namespace summary item list from the
        /// project file.
        /// </summary>
        /// <param name="xr">The XML text reader from which the information
        /// is loaded.</param>
        /// <param name="schemaVersion">The schema version</param>
        internal void ReadXml(XmlTextReader xr, Version schemaVersion)
        {
            NamespaceSummaryItem nsi;

            while(!xr.EOF && xr.NodeType != XmlNodeType.EndElement)
            {
                if(xr.NodeType == XmlNodeType.Element &&
                  xr.Name == "namespaceSummaryItem")
                {
                    nsi = new NamespaceSummaryItem();
                    nsi.ReadXml(xr, schemaVersion);
                    this.Add(nsi);
                }

                xr.Read();
            }
        }
        #endregion

        #region Properties
        //=====================================================================
        // Properties

        /// <summary>
        /// This read-only property returns true if the collection has
        /// summary items with summary text or items marked as not to be
        /// documented.
        /// </summary>
        public bool HasDefinitions
        {
            get
            {
                foreach(NamespaceSummaryItem nsi in this)
                    if(!nsi.IsDocumented || nsi.Summary.Length != 0)
                        return true;

                return false;
            }
        }

        /// <summary>
        /// Indexer.  This can be used to retrieve the summary information
        /// for the specified namespace.
        /// </summary>
        /// <param name="name">The namespace for which to search</param>
        /// <returns>The namespace summary information if found or null if
        /// not found.</returns>
        public NamespaceSummaryItem this[string name]
        {
            get
            {
                if(name == null || name.Length == 0)
                    name = "(global)";

                foreach(NamespaceSummaryItem nsi in this)
                    if(nsi.Name == name)
                        return nsi;

                return null;
            }
        }
        #endregion

        //=====================================================================
        // Methods, etc.

        /// <summary>
        /// This is used to see if the collection contains an entry for the
        /// specified namespace.
        /// </summary>
        /// <param name="name">The namespace for which to search</param>
        /// <returns>True if found, false if not</returns>
        public bool Contains(string name)
        {
            if(name == null || name.Length == 0)
                name = "(global)";

            foreach(NamespaceSummaryItem nsi in this)
                if(nsi.Name == name)
                    return true;

            return false;
        }

        /// <summary>
        /// This is used to see if the collection contains an entry for the
        /// specified namespace and returns whether or not it is documented.
        /// </summary>
        /// <param name="name">The namespace for which to search</param>
        /// <returns>True if found and it is to be documented or if not found,
        /// false if found and it is not to be documented.</returns>
        public bool IsDocumented(string name)
        {
            return (this[name] != null);
        }

        /// <summary>
        /// This is used to sort the namespace items by name
        /// </summary>
        public void Sort()
        {
            ((List<NamespaceSummaryItem>)this.Items).Sort(
                delegate(NamespaceSummaryItem x, NamespaceSummaryItem y)
                {
                    return Comparer<string>.Default.Compare(x.Name, y.Name);
                });
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior)
United States United States
Eric Woodruff is an Analyst/Programmer for Spokane County, Washington where he helps develop and support various applications, mainly criminal justice systems, using Windows Forms (C#) and SQL Server as well as some ASP.NET applications.

He is also the author of various open source projects for .NET including:

The Sandcastle Help File Builder - A front end and project management system that lets you build help file projects using Microsoft's Sandcastle documentation tools. It includes a standalone GUI and a package for Visual Studio integration.

Visual Studio Spell Checker - A Visual Studio editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with a tool window. This can be installed via the Visual Studio Gallery.

Image Map Controls - Windows Forms and web server controls that implement image maps.

PDI Library - A complete set of classes that let you have access to all objects, properties, parameter types, and data types as defined by the vCard (RFC 2426), vCalendar, and iCalendar (RFC 2445) specifications. A recurrence engine is also provided that allows you to easily and reliably calculate occurrence dates and times for even the most complex recurrence patterns.

Windows Forms List Controls - A set of extended .NET Windows Forms list controls. The controls include an auto-complete combo box, a multi-column combo box, a user control dropdown combo box, a radio button list, a check box list, a data navigator control, and a data list control (similar in nature to a continuous details section in Microsoft Access or the DataRepeater from VB6).

For more information see http://www.EWoodruff.us

Comments and Discussions