Click here to Skip to main content
12,632,326 members (29,782 online)
Click here to Skip to main content


24 bookmarked

Param.NET - An Automated Command-line Parameter Parser

, 19 Oct 2005 CPOL
A library that allows developers to specify the parameters that they expect to receive from the command line and provides an easier way to access them
using System;
using System.Configuration;
using System.Collections;
using System.Xml;

namespace Params
	public class ParamConfigurationSectionHandler : IConfigurationSectionHandler
		#region IConfigurationSectionHandler Members

		public object Create(object parent, object context, System.Xml.XmlNode section)
			if(ParamCollection.ApplicationParameters != null)
				throw(new Exception("ParamCollection already initialized. Use ParamCollection.ApplicationParameters."));

			ParamCollection col = new ParamCollection();

			col.DefaultAllowMultipleValues = Helper.GetBool(section.Attributes, "defaultAllowMultiple", false);
			col.DefaultIsOptional = Helper.GetBool(section.Attributes, "defaultOptional", false);
			col.DefaultType = (ParamType)Helper.GetEnum(section.Attributes, "defaultType", ParamType.String, typeof(ParamType));

			col.ShortControlString = Helper.GetString(section.Attributes, "shortControlString", "-");
			col.LongControlString = Helper.GetString(section.Attributes, "longControlString", "-");
			col.SeparatorChar = Helper.GetString(section.Attributes, "separatorChar", " ")[0];
			col.AttribChars = Helper.GetString(section.Attributes, "attribChars", " ").ToCharArray();
			col.AutoGenerateParams = Helper.GetBool(section.Attributes, "autoGenerateParams", false);

			foreach(XmlNode param in section.ChildNodes)
				if(param.NodeType == XmlNodeType.Element && param.Name.ToLower() == "param")
					col.Add(new Param(param, col));

			return col;


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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Romania Romania
Just you average programmer geek from Romania. Student at Faculty of Computer Science, Al. I. Cuza University Iasi, Romania.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161208.2 | Last Updated 20 Oct 2005
Article Copyright 2005 by eugen.anghel
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid