Class TypeConversion
Helper class to handle type conversion during properties API calls.
Namespace: Unity.Properties
Syntax
public static class TypeConversion
Methods
Convert<TSource, TDestination>(TSource)
Converts the specified value from TSource to TDestination.
Declaration
public static TDestination Convert<TSource, TDestination>(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>(ConvertDelegate<TSource, TDestination>)
Registers a new converter from TSource to TDestination.
Declaration
public static void Register<TSource, TDestination>(ConvertDelegate<TSource, TDestination> convert)
Parameters
| Type | Name | Description |
|---|---|---|
| ConvertDelegate<TSource, TDestination> | convert |
Type Parameters
| Name | Description |
|---|---|
| TSource | |
| TDestination |
TryConvert<TSource, TDestination>(TSource, out TDestination)
Converts the specified value from TSource to TDestination.
Declaration
public static bool TryConvert<TSource, TDestination>(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 | true if the conversion succeeded; otherwise, false. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The source type to convert from. |
| TDestination | The destination type to convert to. |