ReflectorResolveType(TypeName, ResolveTypeOptions) Method
Gets the
Type with the specified
typeName.
When no assembly is defined in
typeName, the type can be defined in any loaded assembly.
Namespace: KGySoft.ReflectionAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.5.0
[CLSCompliantAttribute(false)]
public static Type? ResolveType(
TypeName typeName,
ResolveTypeOptions options = ResolveTypeOptions.TryToLoadAssemblies|ResolveTypeOptions.AllowPartialAssemblyMatch
)
<CLSCompliantAttribute(false)>
Public Shared Function ResolveType (
typeName As TypeName,
Optional options As ResolveTypeOptions = ResolveTypeOptions.TryToLoadAssemblies Or ResolveTypeOptions.AllowPartialAssemblyMatch
) As Type
public:
[CLSCompliantAttribute(false)]
static Type^ ResolveType(
TypeName^ typeName,
ResolveTypeOptions options = ResolveTypeOptions::TryToLoadAssemblies|ResolveTypeOptions::AllowPartialAssemblyMatch
)
[<CLSCompliantAttribute(false)>]
static member ResolveType :
typeName : TypeName *
?options : ResolveTypeOptions
(* Defaults:
let _options = defaultArg options ResolveTypeOptions.TryToLoadAssemblies|ResolveTypeOptions.AllowPartialAssemblyMatch
*)
-> Type
- typeName TypeName
- A pre-parsed TypeName instance with or without assembly name.
- options ResolveTypeOptions (Optional)
- The options for resolving the type. This parameter is optional.
Default value: TryToLoadAssemblies, AllowPartialAssemblyMatch.
TypeThe resolved
Type, or
if
the
ThrowError flag is not enabled in
options and
typeName could not be resolved with the provided
options.
The default value of the
options parameter allows loading assemblies if
typeName
is an assembly qualified name. This behavior is compatible with the
Type.GetType method but
can be a security risk if
typeName is from an untrusted source, e.g. file, user input, remote service, database, etc.
In such cases do not enable the
TryToLoadAssemblies flag so the type can be resolved from the already loaded assemblies only.
typeName can be generic and may contain fully or partially defined assembly names.