C# Class Castle.Components.Binder.DefaultConverter

Inheritance: System.MarshalByRefObject, IConverter
显示文件 Open project: nats/castle-1.0.3-mono Class Usage Examples

Public Methods

Method Description
CanConvert ( Type desiredType, Type inputType, object input, bool &exactMatch ) : bool
Convert ( Type desiredType, Type inputType, object input, bool &conversionSucceeded ) : object
Convert ( Type desiredType, object input, bool &conversionSucceeded ) : object

Convert the input param into the desired type

There are 3 possible cases when trying to convert: 1) Input data for conversion missing (input is null or an empty String) Returns default conversion value (based on desired type) and set conversionSucceeded = false 2) Has input data but cannot convert to particular type Throw exception and set conversionSucceeded = false 3) Has input data and can convert to particular type Return input converted to desired type and set conversionSucceeded = true

Private Methods

Method Description
ConvertDate ( object input, bool &conversionSucceeded ) : object
ConvertDecimal ( object input, bool &conversionSucceeded ) : object
ConvertEnum ( Type desiredType, object input, bool &conversionSucceeded ) : object
ConvertGenericList ( Type desiredType, object input, bool &conversionSucceeded ) : object
ConvertGuid ( object input, bool &conversionSucceeded ) : object
ConvertNullable ( Type desiredType, object input, bool &conversionSucceeded ) : object
ConvertPrimitive ( Type desiredType, object input, bool &conversionSucceeded ) : object
ConvertToArray ( Type desiredType, object input, bool &conversionSucceeded ) : object
ConvertUsingTypeConverter ( Type desiredType, object input, bool &conversionSucceeded ) : object

Support for types that specify a TypeConverter, i.e.: NullableTypes

FixInputForMonoIfNeeded ( Type elemType, object input ) : object

Fix for mod_mono issue where array values are passed as a comma seperated String.

IsBool ( Type desiredType ) : bool
NormalizeInput ( object input ) : String
SpecialBoolConversion ( string value, object input, bool &conversionSucceeded ) : object
ThrowInformativeException ( Type desiredType, object input, Exception inner ) : void

Method Details

CanConvert() public method

public CanConvert ( Type desiredType, Type inputType, object input, bool &exactMatch ) : bool
desiredType System.Type
inputType System.Type
input object
exactMatch bool
return bool

Convert() public method

public Convert ( Type desiredType, Type inputType, object input, bool &conversionSucceeded ) : object
desiredType System.Type
inputType System.Type
input object
conversionSucceeded bool
return object

Convert() public method

Convert the input param into the desired type
There are 3 possible cases when trying to convert: 1) Input data for conversion missing (input is null or an empty String) Returns default conversion value (based on desired type) and set conversionSucceeded = false 2) Has input data but cannot convert to particular type Throw exception and set conversionSucceeded = false 3) Has input data and can convert to particular type Return input converted to desired type and set conversionSucceeded = true
public Convert ( Type desiredType, object input, bool &conversionSucceeded ) : object
desiredType System.Type Type of the desired
input object The input
conversionSucceeded bool if false the return value must be ignored
return object