November Happy Hour will be moved to Thursday December 5th.

Class TypeResolver

Helper class to resolve System.Type from Assembly Qualified Names

Inheritance
System.Object
TypeResolver
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Data.Dynamic
Assembly: EPiServer.Data.dll
Version: 11.20.7
Syntax
public static class TypeResolver

Properties

AutoResolve

A System.Boolean indicating if type name should be automatically resolved to the System.Type

Declaration
public static bool AutoResolve { get; set; }
Property Value
Type Description
System.Boolean
Remarks

See the GetType(String, Boolean) method for more information

PrivateProbingPath

Declaration
public static string PrivateProbingPath { get; set; }
Property Value
Type Description
System.String

Methods

ClearCache()

Clear the cache of Assembly Qualified Names to types

Declaration
public static void ClearCache()

GetType(String)

Declaration
public static Type GetType(string typeName)
Parameters
Type Name Description
System.String typeName
Returns
Type Description
System.Type

GetType(String, Boolean)

Tries to resolve the typeName to a System.Type

Declaration
public static Type GetType(string typeName, bool throwOnError)
Parameters
Type Name Description
System.String typeName

A typeName for a type, can be an Assembly Qualified Name for a type

System.Boolean throwOnError

true to throw an exception if the type cannot be found; false to return null

Returns
Type Description
System.Type

The System.Type with the specified name, if found; otherwise, null

Remarks

When the AutoResolve property is set to false then only System.Type.GetType is used to resolve typeName to a System.Type. This allows assembly redirects to be used as an alternative to the auto resolve mechanism this class supplies. When set to false then the following sequence is used:

  1. Try to resolve the typeName to a System.Type using the System.Type.GetType(System.String,System.Boolean,System.Boolean) method
  2. If typeName is a Assembly Qualified Name then all version numbers are removed from the typeName and then try again using System.Type.GetType(System.String,System.Boolean,System.Boolean)
  3. Remove all information except namespace and class names from the Assembly Qualified Name and then try again using System.Type.GetType(System.String,System.Boolean,System.Boolean) Once an typeName has been resolved to a System.Type then that information is cached.
See Also
System.Type.AssemblyQualifiedName

GetType(String, Boolean, FallbackTypeResolver)

Tries to resolve the typeName to a System.Type

Declaration
public static Type GetType(string typeName, bool throwOnError, FallbackTypeResolver fallbackResolver)
Parameters
Type Name Description
System.String typeName

An Assembly Qualified Name for a type

System.Boolean throwOnError

true to throw an exception if the type cannot be found; false to return null

FallbackTypeResolver fallbackResolver

The fallback resolver.

Returns
Type Description
System.Type

The System.Type with the specified name, if found; otherwise, null

Remarks

When the AutoResolve property is set to false then only System.Type.GetType is used to resolve an Assembly Qualified Name to a System.Type. This allows assembly redirects to be used as an alternative to the auto resolve mechanism this class supplies. When set to false then the following sequence is used:

  1. Try to resolve the Assembly Qualified Name to a System.Type using the System.Type.GetType(System.String,System.Boolean,System.Boolean) method
  2. Remove all version numbers from the Assembly Qualified Name and then try again using System.Type.GetType(System.String,System.Boolean,System.Boolean)
  3. Remove all information except namespace and class names from the Assembly Qualified Name and then try again using System.Type.GetType(System.String,System.Boolean,System.Boolean) Once an Assembly Qualified Name has been resolved to a System.Type then that information is cached.
See Also
System.Type.AssemblyQualifiedName

See Also

System.Type.AssemblyQualifiedName