Show / Hide Table of Contents

Class TypeConversion

Inheritance
System.Object
TypeConversion
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: StansAssets.Foundation
Assembly: cs.temp.dll.dll
Syntax
public static class TypeConversion

Methods

Convert(Object, Type)

Converts given the value to the destination type

Declaration
public static object Convert(object source, Type type)
Parameters
Type Name Description
System.Object source
System.Type type
Returns
Type Description
System.Object

Convert<TDestination>(Object)

Converts given the value to the destination type

Declaration
public static TDestination Convert<TDestination>(object source)
Parameters
Type Name Description
System.Object source
Returns
Type Description
TDestination
Type Parameters
Name Description
TDestination
Exceptions
Type Condition
System.Exception

Convert<TSource, TDestination>(TSource)

Converts given the value to the destination type

@NOTE Fastest conversion method

Declaration
public static TDestination Convert<TSource, TDestination>(TSource value)
Parameters
Type Name Description
TSource value

Value to convert to.

Returns
Type Description
TDestination

Converted value.

Type Parameters
Name Description
TSource

Source type.

TDestination

Conversion Destination type.

Register<TSource, TDestination>(Func<TSource, TDestination>)

Registers a new type conversion from the given source type to the given destination type.

Declaration
public static void Register<TSource, TDestination>(Func<TSource, TDestination> conversion)
Parameters
Type Name Description
System.Func<TSource, TDestination> conversion

Conversion delegate method.

Type Parameters
Name Description
TSource

Input type.

TDestination

Output type.

TryConvert<TValue>(Object, out TValue)

Try convert the given value to the destination type

Declaration
public static bool TryConvert<TValue>(object value, out TValue result)
Parameters
Type Name Description
System.Object value
TValue result
Returns
Type Description
System.Boolean
Type Parameters
Name Description
TValue

Unregister<TSource, TDestination>()

Unregisters the converter for the given (TSource, TDestination) pair.

Declaration
public static void Unregister<TSource, TDestination>()
Type Parameters
Name Description
TSource
TDestination
In This Article
Back to top Generated by DocFX