.NET Portable TypeCast
3.1.0.4
A, easy-to-use tested, generic, portable, runtime-extensible, arbitrary type converter library
|
The Converter base class, providing a simple container for conversion types, ConverterAttribute and corresponding conversion functions More...
Public Member Functions | |
abstract object | Convert (object value, object defaultValue=null) |
The converter function as part of the IConverter interface support. More... | |
override string | ToString () |
Overrides object.ToString() to provide a string representation of the underlying conversion types More... | |
string | ToString (bool fullName) |
Overrides object.ToString() to provide information about the conversion types More... | |
Protected Member Functions | |
Converter (Type from, Type to, Type argument=null, Type baseType=null, ConverterAttribute attribute=null) | |
Initializes a new instance of the Core.TypeCast.Base.Converter class. More... | |
abstract void | CheckConvertTypes (object value, object defaultValue) |
Checks the types being in the correct source and target format, if not an Exception is thrown. More... | |
Properties | |
TypeInfo | Argument [get, set] |
The
of the argument passed to Converter.FunctionDefault More... | |
virtual TypeInfo | ArgumentStandard [get] |
Returns true if the Argument-Typeis the default value object. As all converters are contained in strongly typed Converter<TIn, TOut, TArg> 's the argument is set to object if unused. However explicit conversion to the object is still possible. More... | |
ConverterAttribute | Attribute = typeof(object).GetTypeInfo() [get, set] |
Gets or sets the ConverterAttribute if the custom converter class has one defined, else it is set null . More... | |
object | Base [get, set] |
Gets the reference to the Base instance of Type BaseType if one exists, otherwise the value is null . More... | |
TypeInfo | BaseType [get, set] |
Gets the underlying Type of the custom converter class if one exists, otherwise the value is null . More... | |
IConverterCollection | Collection [get, set] |
Gets or sets the underlying ConverterCollection if the converter has been added to one, otherwise the value is null . More... | |
bool | AllowDisambiguates [get, set] |
Optional bool value to indicate whether a ConverterCollection is allowed to contain multiple converters with the same source and target Types in the collection of Items. Only set to true for transform functions. More... | |
bool | DefaultValueAnyType [get, set] |
Gets or sets a value indicating whether the second argument of Converter.FunctionDefault is Type-checked to enforce type quality with the return Type of the Function More... | |
TypeInfo | From [get] |
Gets the Type of the object instance which is to be converted. More... | |
object | Function [get, set] |
The boxed converter function of Type.DeclaringType IConverter<TIn,TOut>.Convert More... | |
MethodInfo | FunctionInfo [get, set] |
Gets an instance of MethodInfo describing the Function. May be null if the converter constructor was not passed a MethodInfo instance. More... | |
ConverterMethodAttribute | FunctionAttribute [get, set] |
Gets an instance of ConverterMethodAttribute of the Function if it exists. May also be null if the attribute property has not been set. More... | |
object | FunctionDefault [get, set] |
The boxed converter function with an additional second argument value that allows passing a any arbitrary or default-value which may be returned in case of conversion failure or the conversion result yielding null . It may also be used as an essential argument for ObjectExtension.ConvertTo<TIn, TOut>(TIn, object) More... | |
MethodInfo | FunctionDefaultInfo [get, set] |
Gets an instance of MethodInfo describing the FunctionDefault. May be null if the converter constructor was not passed a MethodInfo instance. More... | |
ConverterMethodAttribute | FunctionDefaultAttribute [get, set] |
Gets an instance of ConverterMethodAttribute of the FunctionDefault if it exists. May also be null if the attribute property has not been set. More... | |
bool | HasDefaultFunction [get] |
Gets a value indicating whether the converter has a FunctionDefault set. More... | |
bool | HasDefaultFunctionOnly [get] |
Gets a value indicating whether the converter has only a FunctionDefault set. More... | |
bool | HasFunction [get] |
Gets a value indicating whether the converter has either Function or FunctionDefault set. More... | |
bool | Standard [get] |
Gets a value indicating whether the Converter instance is strictly typed such that the
| |
string | NameSpace [get] |
Gets the Type.Namespace that the Converter instance is assigned to, with the possibility of many converters declaring the same namespace , that is using a one to many relationship. The handling of the NameSpace lies within the responsibility of the ConverterCollection More... | |
TypeInfo | To [get] |
Gets the Type that the instance will be converted to. More... | |
bool | UseFunctionDefaultWrapper [get, set] |
Gets or sets a value indicating whether to use a default-value wrapper function if a default-value was passed but no conversion function taking a default-value exists More... | |
The Converter base class, providing a simple container for conversion types, ConverterAttribute and corresponding conversion functions
The Converter is usually invoked through ObjectExtension.CastTo<TOut> and ObjectExtension.TryCast<TIn,TOut>
Definition at line 22 of file Converter.cs.
|
protected |
Initializes a new instance of the Core.TypeCast.Base.Converter class.
from | The source/from conversion Type |
to | The target/to conversion Type |
argument | The
|
baseType | The Type of any underlying converter class if one exists |
attribute | The ConverterAttribute of the converter-class if present. |
Only invoked by Converter<TIn,TOut>
Definition at line 39 of file Converter.cs.
|
protectedpure virtual |
Checks the types being in the correct source and target format, if not an Exception is thrown.
value | The value to be converted. |
defaultValue | The optional default value to be passed if the conversion fails or is null . |
ConverterException | Throws exceptions based on mismatching types or null references |
Implemented in Core.TypeCast.Converter< TIn, TOut, TArg >.
|
pure virtual |
The converter function as part of the IConverter interface support.
value | The value to be converted. |
defaultValue | The optional default value to be passed if the conversion fails or is null . |
The actual implementation and use of the second parameter lies solely within the scope of the programmer implementing the converter logic
Implemented in Core.TypeCast.Converter< TIn, TOut, TArg >.
override string Core.TypeCast.Base.Converter.ToString | ( | ) |
Overrides object.ToString() to provide a string representation of the underlying conversion types
Definition at line 260 of file Converter.cs.
string Core.TypeCast.Base.Converter.ToString | ( | bool | fullName | ) |
Overrides object.ToString() to provide information about the conversion types
fullName | Whether to show the full reflected name information |
Definition at line 271 of file Converter.cs.
|
getset |
Optional bool value to indicate whether a ConverterCollection is allowed to contain multiple converters with the same source and target Types in the collection of Items. Only set to true
for transform functions.
Definition at line 94 of file Converter.cs.
|
getset |
The
of the argument passed to Converter.FunctionDefault
Definition at line 55 of file Converter.cs.
|
get |
Returns true
if the Argument-Typeis the default value object. As all converters are contained in strongly typed Converter<TIn, TOut, TArg> 's the argument is set to object if unused. However explicit conversion to the object is still possible.
Definition at line 61 of file Converter.cs.
|
getset |
Gets or sets the ConverterAttribute if the custom converter class has one defined, else it is set null
.
The value is set once upon first access and is not updated thereafter, unless reset to null
Definition at line 67 of file Converter.cs.
|
getset |
Gets the reference to the Base instance of Type BaseType if one exists, otherwise the value is null
.
Definition at line 79 of file Converter.cs.
|
getset |
Gets the underlying Type of the custom converter class if one exists, otherwise the value is null
.
Definition at line 84 of file Converter.cs.
|
getset |
Gets or sets the underlying ConverterCollection if the converter has been added to one, otherwise the value is null
.
Definition at line 87 of file Converter.cs.
|
getset |
Gets or sets a value indicating whether the second argument of Converter.FunctionDefault is Type-checked to enforce type quality with the return Type of the Function
Definition at line 102 of file Converter.cs.
|
get |
Gets the Type of the object instance which is to be converted.
Definition at line 106 of file Converter.cs.
|
getset |
The boxed converter function of Type.DeclaringType IConverter<TIn,TOut>.Convert
null
if no function is setDefinition at line 112 of file Converter.cs.
|
getset |
Gets an instance of ConverterMethodAttribute of the Function if it exists. May also be null
if the attribute property has not been set.
null
if no function is setDefinition at line 126 of file Converter.cs.
|
getset |
The boxed converter function with an additional second argument value that allows passing a any arbitrary or default-value which may be returned in case of conversion failure or the conversion result yielding null
. It may also be used as an essential argument for ObjectExtension.ConvertTo<TIn, TOut>(TIn, object)
null
if no function is setThe actual implementation and use of the second parameter lies solely within the scope of the programmer implementing the converter logic
Definition at line 135 of file Converter.cs.
|
getset |
Gets an instance of ConverterMethodAttribute of the FunctionDefault if it exists. May also be null
if the attribute property has not been set.
null
if no function is setDefinition at line 149 of file Converter.cs.
|
getsetprotected |
Gets an instance of MethodInfo describing the FunctionDefault. May be null if the converter constructor was not passed a MethodInfo instance.
null
if no function is setDefinition at line 142 of file Converter.cs.
|
getsetprotected |
Gets an instance of MethodInfo describing the Function. May be null if the converter constructor was not passed a MethodInfo instance.
null
if no function is setDefinition at line 119 of file Converter.cs.
|
get |
Gets a value indicating whether the converter has a FunctionDefault set.
Definition at line 154 of file Converter.cs.
|
get |
Gets a value indicating whether the converter has only a FunctionDefault set.
Definition at line 164 of file Converter.cs.
|
get |
Gets a value indicating whether the converter has either Function or FunctionDefault set.
Definition at line 174 of file Converter.cs.
|
get |
Gets the Type.Namespace that the Converter instance is assigned to, with the possibility of many converters declaring the same namespace , that is using a one to many relationship. The handling of the NameSpace lies within the responsibility of the ConverterCollection
The namespace is used for grouping, filtering and on-demand loading purposes.
Definition at line 212 of file Converter.cs.
|
get |
Gets a value indicating whether the Converter instance is strictly typed such that the
Type is set to the Type of To.
inherits from . Due to the strictly-typed nature of the converter instances the is only passes a default-value if the passed value is of the same type as To. This property allows quick lookups.
Definition at line 192 of file Converter.cs.
|
get |
Gets the Type that the instance will be converted to.
Definition at line 216 of file Converter.cs.
|
getset |
Gets or sets a value indicating whether to use a default-value wrapper function if a default-value was passed but no conversion function taking a default-value exists
Definition at line 225 of file Converter.cs.