Click or drag to resize

HostFunctions Class

Provides optional script-callable utility functions.
Inheritance Hierarchy
SystemObject
  Microsoft.ClearScriptHostFunctions
    Microsoft.ClearScriptExtendedHostFunctions

Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.3.7
Syntax
public class HostFunctions : IScriptableObject

The HostFunctions type exposes the following members.

Constructors
 NameDescription
Public methodHostFunctions Initializes a new HostFunctions instance.
Top
Methods
 NameDescription
Public methodCode exampleasTypeT Casts an object to the specified host type, returning null if the cast fails.
Public methodCode examplecastT Casts an object to the specified host type.
Public methodCode exampledelT Creates a delegate that invokes a script function.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodCode exampleflagsT Creates a strongly typed flag set.
Public methodfunc(Int32, Object) Creates a delegate that invokes a script function and returns its result value.
Public methodCode examplefuncT(Int32, Object) Creates a delegate that invokes a script function and returns a value of the specified type.
Public methodgetElement Gets the value of an element in a dynamic host object that implements IDynamicMetaObjectProvider.
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodgetProperty(IDynamicMetaObjectProvider, String) Gets the value of a property in a dynamic host object that implements IDynamicMetaObjectProvider.
Public methodgetProperty(IPropertyBag, String) Gets the value of a property in a dynamic host object that implements IPropertyBag.
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodisNull Determines whether the specified value is null.
Public methodCode exampleisTypeT Determines whether an object is compatible with the specified host type.
Public methodisTypeObj(Object) Determines whether an object is a host type. This version is invoked if the specified object cannot be used as a type argument.
Public methodisTypeObjT Determines whether an object is a host type. This version is invoked if the specified object can be used as a type argument.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodnewArr(Int32) Creates a host array with Object as the element type.
Public methodCode examplenewArrT(Int32) Creates a host array with the specified element type.
Public methodCode examplenewObj Creates an empty host object.
Public methodnewObj(IDynamicMetaObjectProvider, Object) Performs dynamic instantiation.
Public methodnewObj(Object, Object) Creates a host object of the specified type. This version is invoked if the specified type cannot be used as a type argument.
Public methodCode examplenewObjT(Object) Creates a host object of the specified type. This version is invoked if the specified type can be used as a type argument.
Public methodCode examplenewVarT Creates a host variable of the specified type.
Public methodCode exampleproc Creates a delegate that invokes a script function and returns no value.
Public methodremoveElement Removes an element from a dynamic host object that implements IDynamicMetaObjectProvider.
Public methodremoveProperty(IDynamicMetaObjectProvider, String) Removes a property from a dynamic host object that implements IDynamicMetaObjectProvider.
Public methodremoveProperty(IPropertyBag, String) Removes a property from a dynamic host object that implements IPropertyBag.
Public methodsetElement Sets an element value in a dynamic host object that implements IDynamicMetaObjectProvider.
Public methodsetProperty(IDynamicMetaObjectProvider, String, Object) Sets a property value in a dynamic host object that implements IDynamicMetaObjectProvider.
Public methodsetProperty(IPropertyBag, String, Object) Sets a property value in a dynamic host object that implements IPropertyBag.
Public methodCode exampletoByte Converts the specified value to a strongly typed Byte instance.
Public methodCode exampletoChar Converts the specified value to a strongly typed Char instance.
Public methodCode exampletoDecimal Converts the specified value to a strongly typed Decimal instance.
Public methodCode exampletoDouble Converts the specified value to a strongly typed Double instance.
Public methodCode exampletoInt16 Converts the specified value to a strongly typed Int16 instance.
Public methodCode exampletoInt32 Converts the specified value to a strongly typed Int32 instance.
Public methodCode exampletoInt64 Converts the specified value to a strongly typed Int64 instance.
Public methodCode exampletoSByte Converts the specified value to a strongly typed SByte instance.
Public methodCode exampletoSingle Converts the specified value to a strongly typed Single instance.
Public methodtoStaticType Casts a dynamic host object to its static type.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Public methodCode exampletoUInt16 Converts the specified value to a strongly typed UInt16 instance.
Public methodCode exampletoUInt32 Converts the specified value to a strongly typed UInt32 instance.
Public methodCode exampletoUInt64 Converts the specified value to a strongly typed UInt64 instance.
Public methodCode exampletryCatch Allows script code to handle host exceptions.
Public methodCode exampletypeOf(Object) Gets the Type for the specified host type. This version is invoked if the specified object cannot be used as a type argument.
Public methodCode exampletypeOfT Gets the Type for the specified host type. This version is invoked if the specified object can be used as a type argument.
Top
Remarks
Use AddHostObject to expose a HostFunctions instance to script code. Each instance can only be exposed in one script engine.
See Also