Skip to main content

Class TypeExtensions

Namespace: RealityCollective.ServiceFramework.Extensions

public static class TypeExtensions

Inheritance

object ← TypeExtensions

Methods

FindTopmostGenericTypeArguments(Type, int)

Recursively looks for generic type arguments in type hierarchy, starting with the root type provided. If no generic type arguments are found on a type, it's base type is checked.

public static Type[] FindTopmostGenericTypeArguments(this Type root, int maxRecursionDepth = 5)

Parameters

root Type

Root type to start looking for generic type arguments at.

maxRecursionDepth int

The maximum recursion depth until execution gets canceled even if no results found.

Returns

Type[]

Found generic type arguments array or null, if none found.

TryResolveType(Guid, out Type)

Attempts to resolve the type using the class Guid.

public static bool TryResolveType(Guid guid, out Type resolvedType)

Parameters

guid Guid

Class Guid reference.

resolvedType Type

The resolved Type.

Returns

bool

true if the resolvedType was successfully obtained from or added to the TypeCache, otherwise false.

TryResolveType(string, out Type)

Attempts to resolve the type using a the AssemblyQualifiedName or GUID as String.

public static bool TryResolveType(string typeRef, out Type resolvedType)

Parameters

typeRef string

The GUID or AssemblyQualifiedName as String.

resolvedType Type

The resolved Type.

Returns

bool

True if the resolvedType was successfully obtained from or added to the TypeCache, otherwise false.