-
Notifications
You must be signed in to change notification settings - Fork 5
Add a converter
As MGR.CommandLineParser lets you define your options as typed property, it should convert the string-based arguments to the type of your property.
To achieve that, MGR.CommandLineParser defines (and uses) MGR.CommandLineParser.Converters.IConverter. This interface defines a property (TargetType) to let know to the parser on which property the converter can be applied, and a method (Convert) that take the string-based arguments and the type of the property, and return the converted value.
To find which converter to use, the parser will look if an attribute MGR.CommandLineParser.Command.ConverterAttribute is applied to the property (MGR.CommandLineParser.Command.ConverterKeyValueAttribute for dictionary properties). If this is not the case, the parser will browse the collection of registred converters (see dependency resolver) if one can apply.
The built-in converters can convert to these types : bool, byte, char, DateTime, decimal, DirectoryInfo, double, Enum, FileInfo, Guid, Int16, Int32, Int64, single, string, TimeSpan, Uri.