ClearScript Library
ClearScript Library
ClearScript Library Reference
Microsoft.ClearScript
ExtendedHostFunctions Class
ExtendedHostFunctions Methods
type Method
type(Type) Method
type(String, Object[]) Method
type(String, String, Object[]) Method

# ExtendedHostFunctionstype(String, String, Object) Method

Imports a host type by name from the specified assembly.
Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.5.0
Syntax
C#
VB
C++
F#
Copy

    public Object type(
    	string name,
    	string assemblyName,
    	params Object[] hostTypeArgs
    )

    Public Function type (
    	name As String,
    	assemblyName As String,
    	ParamArray hostTypeArgs As Object()
    ) As Object

    public:
    Object^ type(
    	String^ name,
    	String^ assemblyName,
    	... array<Object^>^ hostTypeArgs
    )

    member type :
            name : string *
            assemblyName : string *
            hostTypeArgs : Object[] -> Object

#### Parameters

name String
  The fully qualified name of the host type to import.
assemblyName String
  The name of the assembly that contains the host type to import.
hostTypeArgs Object
  Optional generic type arguments.

#### Return Value

Object
The 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.

Example
The following code imports Enumerable and uses it to create an array of strings. It assumes that an instance of ExtendedHostFunctions is exposed under the name "host" (see AddHostObject).
JavaScript
Copy

    var EnumerableT = host.type("System.Linq.Enumerable", "System.Core");
    var Int32T = host.type("System.Int32");
    var StringT = host.type("System.String");
    var SelectorT = host.type("System.Func", Int32T, StringT);
    var selector = host.del(SelectorT, function (num) { return StringT.Format("The number is {0}.", num); });
    var array = EnumerableT.Range(0, 5).Select(selector).ToArray();

See Also

#### Reference

ExtendedHostFunctions Class
type Overload
Microsoft.ClearScript Namespace
type(String, Object)

Copyright © Microsoft Corporation. All rights reserved.

Send comments on this topic to Microsoft