Class EqualityTypeConverter
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
The default converter, simply converts between types that are equal or can be converted (i.e. Button => UIControl).
public class EqualityTypeConverter : IBindingTypeConverter, IEnableLogger
- Inheritance
-
EqualityTypeConverter
- Implements
-
IEnableLogger
- Extension Methods
Constructors
EqualityTypeConverter()
public EqualityTypeConverter()
Methods
DoReferenceCast(object?, Type)
Handles casting for a reference. Understands about nullable types and can cast appropriately.
public static object? DoReferenceCast(object? from, Type targetType)
Parameters
Returns
- object
The new value after it has been casted.
Exceptions
- InvalidCastException
If we cannot cast the object.
GetAffinityForObjects(Type, Type)
Returns a positive integer when this class supports TryConvert for this particular Type. If the method isn't supported at all, return a non-positive integer. When multiple implementations return a positive value, the host will use the one which returns the highest value. When in doubt, return '2' or '0'.
public int GetAffinityForObjects(Type fromType, Type toType)
Parameters
Returns
- int
A positive integer if TryConvert is supported, zero or a negative value otherwise.
TryConvert(object?, Type, object?, out object?)
Convert a given object to the specified type.
public bool TryConvert(object? from, Type toType, object? conversionHint, out object? result)
Parameters
fromobjectThe object to convert.
toTypeTypeThe type to coerce the object to.
conversionHintobjectAn implementation-defined value, usually to specify things like locale awareness.
resultobjectAn object that is of the type
toType.
Returns
- bool
True if conversion was successful.