Click or drag to resize

ScriptEngineAddHostObject(String, HostItemFlags, Object) Method

Exposes a host object to script code with the specified options.

Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.3.7
Syntax
public void AddHostObject(
	string itemName,
	HostItemFlags flags,
	Object target
)

Parameters

itemName  String
A name for the new global script item that will represent the object.
flags  HostItemFlags
A value that selects options for the operation.
target  Object
The object to expose.

Implements

IScriptEngineAddHostObject(String, HostItemFlags, Object)
Remarks

Once a host object is exposed to script code, its members are accessible via the script language's native syntax for member access. The following table provides details about the mapping between host members and script-accessible properties and methods.

Member TypeExposed AsRemarks
ConstructorN/A To invoke a constructor from script code, call HostFunctions.newObj(T).
Property/FieldPropertyN/A
MethodMethod Overloaded host methods are merged into a single script-callable method. At runtime the correct host method is selected based on the argument types.
Generic MethodMethod The ClearScript library supports dynamic C#-like type inference when invoking generic methods. However, some methods require explicit type arguments. To call such a method from script code, you must place the required number of host type objects at the beginning of the argument list. Doing so for methods that do not require explicit type arguments is optional.
Extension MethodMethod Extension methods are available if the type that implements them has been exposed in the current script engine.
IndexerProperty Indexers appear as properties named "Item" that accept one or more index values as arguments. In addition, objects that implement IList expose properties with numeric names that match their valid indices. This includes one-dimensional host arrays and other collections. Multidimensional host arrays do not expose functional indexers; you must use Array.GetValue and Array.SetValue instead.
EventProperty Events are exposed as read-only properties of type EventSourceT.

See Also