ScriptEngineAddHostObject Method (String, HostItemFlags, Object) |
Namespace: Microsoft.ClearScript
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 Type | Exposed As | Remarks |
---|---|---|
Constructor | N/A | To invoke a constructor from script code, call HostFunctions.newObj(T). |
Property/Field | Property | N/A |
Method | Method | 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 Method | Method | 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 Method | Method | Extension methods are available if the type that implements them has been exposed in the current script engine. |
Indexer | Property | 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. |
Event | Property | Events are exposed as read-only properties of type EventSourceT. |