Click or drag to resize

HostFunctionstypeOfT Method

Gets the Type for the specified host type. This version is invoked if the specified object can be used as a type argument.

Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.4.0
public Type typeOf<T>()

Type Parameters

The host type for which to get the Type.

Return Value

The Type for the specified host type.

This function is similar to C#'s typeof operator. It is overloaded with typeOf(Object) and selected at runtime if T can be used as a type argument.

This function throws an exception if the script engine's AllowReflection property is set to false.

The following code retrieves the assembly-qualified name of a host type. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
var StringT = host.type("System.String");
var name = host.typeOf(StringT).AssemblyQualifiedName;
See Also