This project has moved and is read-only. For the latest updates, please go here.

MGR.CommandLineParser.Extensibility.IConverter Reference

This interface defines a converter used by the parser to assign value to the command's options. The converter always converts from System.String (typed by the user).


  • object Convert(string value, Type concreteTargetType) : Converts a value to the specified concreteTargetType. This second argument exists to allow you to write a unique generic converter for the target type IFoo, and have options with different implementation of IFoo (FooImpl, Foo, etc...). It is used internally to convert to System.Enum.


  • Type TargetType {get; } : Gets the target type of the converter.

Default implementation

MGR.CommandLineParser offers (and registers) implementations of IConverter for several common types :
  • System.Boolean : BooleanConverter
  • System.Byte : ByteConverter
  • System.Char : CharConverter
  • System.DateTime : DateTimeConverter
  • System.Decimal : DecimalConverter
  • System.Double : DoubleConverter
  • System.Enum: EnumConverter
  • System.Guid : GuidConverter
  • System.Int16 : Int16Converter
  • System.Int32 : Int32Converter
  • System.Int64 : Int64Converter
  • System.Single : SingleConverter
  • System.String : StringConverter
  • System.TimeSpan : TimeSpanConverter
  • System.Uri : UriConverter

If you need an option with a dictionary, MGR.CommandLineParser have a build-in mechanism to allow it. See ConverterKeyValueAttribute.

Last edited Apr 20, 2012 at 12:18 PM by mgrosperrin, version 4