ExtendedHostFunctionstype Method (String, Object) |
Imports a host type by name.
Namespace:
Microsoft.ClearScript
Assembly:
ClearScript.Core (in ClearScript.Core.dll) Version: 7.2.3
Syntaxpublic Object type(
string name,
params Object[] hostTypeArgs
)
Public Function type (
name As String,
ParamArray hostTypeArgs As Object()
) As Object
public:
Object^ type(
String^ name,
... array<Object^>^ hostTypeArgs
)
member type :
name : string *
hostTypeArgs : Object[] -> Object
Parameters
- name
- Type: SystemString
The fully qualified name of the host type to import. - hostTypeArgs
- Type: SystemObject
Optional generic type arguments.
Return Value
Type:
ObjectThe imported host type.
Remarks
Host types are imported in the form of objects whose properties and methods are bound
to the host type's static members and nested types. If name refers
to a generic type, the corresponding object will be invocable with type arguments to
yield a specific type.
For more information about the mapping between host members and script-callable
properties and methods, see
AddHostObject.
Examples
The following code imports the
Dictionary
generic type and uses it to create a string dictionary.
It assumes that an instance of
ExtendedHostFunctions is exposed under
the name "host"
(see
AddHostObject).
var DictT = host.type("System.Collections.Generic.Dictionary");
var StringT = host.type("System.String");
var dict = host.newObj(DictT(StringT, StringT));
Another way to create a string dictionary is to import the specific type directly.
var StringT = host.type("System.String");
var StringDictT = host.type("System.Collections.Generic.Dictionary", StringT, StringT);
var dict = host.newObj(StringDictT);
See Also