Click or drag to resize

HostFunctions Class

Provides optional script-callable utility functions.
Inheritance Hierarchy
System.Object
  Microsoft.ClearScript.HostFunctions
    Microsoft.ClearScript.ExtendedHostFunctions

Namespace: Microsoft.ClearScript
Assembly: ClearScript.Core (in ClearScript.Core.dll) Version: 7.5.0
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 exampleasType<T> Casts an object to the specified host type, returning null if the cast fails.
Public methodCode examplecast<T> Casts an object to the specified host type.
Public methodCode exampledel<T> 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 exampleflags<T> 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 examplefunc<T>(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 exampleisType<T> 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 methodisTypeObj<T>() 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 examplenewArr<T>(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 examplenewObj<T>(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 examplenewVar<T> 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 exampletypeOf<T>() 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