Class TypeResolver
Helper class to resolve System.Type from Assembly Qualified Names
Inheritance
Inherited Members
Namespace: EPiServer.Data.Dynamic
Assembly: EPiServer.Data.dll
Version: 9.12.2Syntax
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:
- Try to resolve the
typeName
to a System.Type using the System.Type.GetType(System.String,System.Boolean,System.Boolean) method - If
typeName
is a Assembly Qualified Name then all version numbers are removed from thetypeName
and then try again using System.Type.GetType(System.String,System.Boolean,System.Boolean) - 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
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:
- Try to resolve the Assembly Qualified Name to a System.Type using the System.Type.GetType(System.String,System.Boolean,System.Boolean) method
- Remove all version numbers from the Assembly Qualified Name and then try again using System.Type.GetType(System.String,System.Boolean,System.Boolean)
- 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.