ParamGate application parameter handling library

Parameter specification

You may have guessed that the default behavior for identifying the parameter name is to use the property name.
As shown in main example on the ParamGate application parameter handling library page, you can customize the name of the parameter. It may not have any white-space or invalid character such as the null terminator, etc.

Each parameter is optional by default unless its marked with the ExcpectedParameter attribute which will throw an error if that parameter (associated with that property) is not specified.
There is also the option of specifying one (and only one) default parameter which means that the user doesn't have to specify the name of the parameter, he may just start supplying values. As discussed later, default parameters may only exist in the beginning of the parameter list, before any other explicitly specified parameters.

Property types may be something other than string. You may have booleans, integers, doubles, string arrays and string collections (non-generic interfaces such as IEnumerable, IList and ICollection are also supported). You may only specify string arrays, no other array type is supported and other generic collections other than string is also not supported.

The current format for specifying parameters to the ParamGateHandler are as follows (Note that this is assuming that you are using the library for command line or GUI tools where a user need to specify input parameters) :

[-DefaultParameterName] [Default value 1] [Default value 2] ... [Default value n] -ParameterName "Parameter value" 
  -BooleanParameterName -CollectionParameter "Item 1" "Item 2" ... "Item n" -AnotherBooleanParameter True/False 
  -IntegerParameter 1 -FilePathParameter "C:\temp\file.txt"

(The above line is broken up into multiple lines for readability sake.)

To clarify, the blocks [ ] indicate optional parameters, values. Its specified in mathematical notation where you can have any number of them.
The default parameter may be omitted but it may not be specified more than once.
The quotes ("") denote string values (generally also used in command line tools for values that have spaces in them).
Only Boolean parameters may be left value-less as this would indicate that the property needs to be set to true.
The True/False denotes that any one of the two may be specified but not both to explicitly specify the Boolean property.
For the integer parameter you can have the value in quotes or without quotes.
Each parameter name must have the dash '-' as prefix to denote a parameter. The value (or values) is always specified after the parameter, separated by spaces.

Last edited Sep 2, 2011 at 5:55 PM by dandrejvv, version 3


No comments yet.