C# Class Command.PluggableTypeConverter

Provides a general purpose and extensible ITypeConverter implementation. String-to-object type conversions can be registered in an instance of this class via lambda functions. Additionally, default mappings are provided for: - string, int, double, and bool primitives - DateTime objects - enums - Arrays and IEnumerable<> of any of the above
Inheritance: ITypeConverter
Show file Open project: agardiner/hfmcmd Class Usage Examples

Protected Properties

Property Type Description
_log log4net.ILog

Public Methods

Method Description
CanConvert ( Type type ) : bool

Returns true if type can be converted, false if it cannot.

ConvertTo ( string value, Type type ) : object

Returns the result of converting the supplied string value to the target type.

PluggableTypeConverter ( ) : System
PluggableTypeConverter ( bool includeDefaults ) : System

Construct a new instance, and registers default conversions if includeDefaults is true.

Remove ( Type type ) : void

Remove the map expression for type.

this ( Type type ) : Func

Returns the conversion function used to convert strings to the specified type.

Protected Methods

Method Description
ConvertArray ( string val, Type type ) : object
ConvertEnum ( string val, Type type ) : object

Method Details

CanConvert() public method

Returns true if type can be converted, false if it cannot.
public CanConvert ( Type type ) : bool
type System.Type
return bool

ConvertArray() protected method

protected ConvertArray ( string val, Type type ) : object
val string
type System.Type
return object

ConvertEnum() protected method

protected ConvertEnum ( string val, Type type ) : object
val string
type System.Type
return object

ConvertTo() public method

Returns the result of converting the supplied string value to the target type.
public ConvertTo ( string value, Type type ) : object
value string
type System.Type
return object

PluggableTypeConverter() public method

public PluggableTypeConverter ( ) : System
return System

PluggableTypeConverter() public method

Construct a new instance, and registers default conversions if includeDefaults is true.
public PluggableTypeConverter ( bool includeDefaults ) : System
includeDefaults bool
return System

Remove() public method

Remove the map expression for type.
public Remove ( Type type ) : void
type System.Type
return void

this() public method

Returns the conversion function used to convert strings to the specified type.
public this ( Type type ) : Func
type System.Type
return Func

Property Details

_log protected static property

protected static ILog,log4net _log
return log4net.ILog