Click here to Skip to main content
15,886,823 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 999.4K   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
// File    : OptionInfo.cs
// Author  : Eric Woodruff
// Updated : 02/23/2007
// Note    : Copyright 2006-2007, Eric Woodruff, All rights reserved
// Compiler: Microsoft Visual C#
//
// This file contains the command line option information class.
//
// 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.3.4.0  12/27/2006  EFW  Created the code
// 1.4.0.0  02/23/2007  EFW  Added support for a third value option
//=============================================================================

using System;
using System.Globalization;
using System.Text.RegularExpressions;

namespace SandcastleBuilderConsole
{
    /// <summary>
    /// This is the console mode version of the Sandcastle Help File Builder.
    /// </summary>
    class OptionInfo
    {
        #region Private data members
        //=====================================================================
        // Private data members

        private static Regex reSplit =
            new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");

        private string optionText, name, value, secondValue, thirdValue;
        #endregion

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

        /// <summary>
        /// Get the option text as specified
        /// </summary>
        public string OptionText
        {
            get { return optionText; }
        }

        /// <summary>
        /// Get the option name
        /// </summary>
        public string Name
        {
            get { return name; }
        }

        /// <summary>
        /// Get the option value
        /// </summary>
        public string Value
        {
            get { return value; }
        }

        /// <summary>
        /// Get the second option value if there was one
        /// </summary>
        public string SecondValue
        {
            get { return secondValue; }
        }

        /// <summary>
        /// Get the third option value if there was one
        /// </summary>
        public string ThirdValue
        {
            get { return thirdValue; }
        }
        #endregion

        //=====================================================================
        // Methods

        /// <summary>
        /// Constructor
        /// </summary>
        public OptionInfo(string option)
        {
            int pos;

            optionText = option.Trim();

            // Is is a project file
            if(optionText[0] != '-' && optionText[0] != '/')
            {
                name = "project";
                value = optionText;
                return;
            }

            pos = optionText.IndexOf('=');

            if(pos < 2)
                name = optionText.Substring(1).ToLower(
                    CultureInfo.InvariantCulture);
            else
            {
                name = optionText.Substring(1, pos - 1).Trim().ToLower(
                    CultureInfo.InvariantCulture);
                value = optionText.Substring(pos + 1).Trim();

                if(reSplit.IsMatch(value))
                {
                    string[] parts = reSplit.Split(value);
                    value = parts[0].Trim();
                    secondValue = parts[1].Trim();

                    if(parts.Length > 2)
                        thirdValue = parts[2].Trim();
                }

                // Strip quotes from around the values
                if(value[0] == '\"')
                    value = value.Substring(1, value.Length - 2).Trim();

                if(!String.IsNullOrEmpty(secondValue) && secondValue[0] == '\"')
                    secondValue = secondValue.Substring(1,
                        secondValue.Length - 2).Trim();

                if(!String.IsNullOrEmpty(thirdValue) && thirdValue[0] == '\"')
                    thirdValue = thirdValue.Substring(1,
                        thirdValue.Length - 2).Trim();
            }
        }
    }
}

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