Class TypeConversion
Helper class to handle type conversion during properties API calls.
Inherited Members
Namespace: Unity.Properties
Syntax
public static class TypeConversion
Methods
Convert<TSource, TDestination>(ref TSource)
Converts the specified value from TSource
to TDestination
.
Declaration
public static TDestination Convert<TSource, TDestination>(ref TSource value)
Parameters
Type | Name | Description |
---|---|---|
TSource | value | The source value to convert. |
Returns
Type | Description |
---|---|
TDestination | The value converted to the |
Type Parameters
Name | Description |
---|---|
TSource | The source type to convert from. |
TDestination | The destination type to convert to. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | No converter is registered for the given types. |
Register<TSource, TDestination>(TypeConverter<TSource, TDestination>)
Registers a new converter from TSource
to TDestination
.
Declaration
public static void Register<TSource, TDestination>(TypeConverter<TSource, TDestination> converter)
Parameters
Type | Name | Description |
---|---|---|
TypeConverter<TSource, TDestination> | converter | Conversion delegate |
Type Parameters
Name | Description |
---|---|
TSource | Type of the source object. |
TDestination | Type of the destination object. |
TryConvert<TSource, TDestination>(ref TSource, out TDestination)
Converts the specified value from TSource
to TDestination
.
Declaration
public static bool TryConvert<TSource, TDestination>(ref TSource source, out TDestination destination)
Parameters
Type | Name | Description |
---|---|---|
TSource | source | The source value to convert. |
TDestination | destination | When this method returns, contains the converted destination value if the conversion succeeded; otherwise, default. |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
TSource | The source type to convert from. |
TDestination | The destination type to convert to. |