C# Class MsieJavaScriptEngine.JsRt.JavaScriptValue

A JavaScript value.
A JavaScript value is one of the following types of values: Undefined, Null, Boolean, String, Number, or Object.
Mostrar archivo Open project: klumsy/PowerShellJS Class Usage Examples

Public Methods

Method Description
AddRef ( ) : uint

Adds a reference to the object.

This only needs to be called on objects that are not going to be stored somewhere on the stack. Calling AddRef ensures that the JavaScript object the value refers to will not be freed until Release is called

CallFunction ( ) : JavaScriptValue

Invokes a function.

Requires an active script context.

ConstructObject ( ) : JavaScriptValue

Invokes a function as a constructor.

Requires an active script context.

ConvertToBoolean ( ) : JavaScriptValue

Converts the value to Boolean using regular JavaScript semantics.

Requires an active script context.

ConvertToNumber ( ) : JavaScriptValue

Converts the value to Number using regular JavaScript semantics.

Requires an active script context.

ConvertToObject ( ) : JavaScriptValue

Converts the value to Object using regular JavaScript semantics.

Requires an active script context.

ConvertToString ( ) : JavaScriptValue

Converts the value to String using regular JavaScript semantics.

Requires an active script context.

CreateArray ( uint length ) : JavaScriptValue

Creates a JavaScript array object.

Requires an active script context.

CreateError ( JavaScriptValue message ) : JavaScriptValue

Creates a new JavaScript error object

Requires an active script context.

CreateExternalObject ( IntPtr data, JavaScriptObjectFinalizeCallback finalizer ) : JavaScriptValue

Creates a new Object that stores some external data.

Requires an active script context.

CreateFunction ( JavaScriptNativeFunction function ) : JavaScriptValue

Creates a new JavaScript function.

Requires an active script context.

CreateFunction ( JavaScriptNativeFunction function, IntPtr callbackData ) : JavaScriptValue

Creates a new JavaScript function.

Requires an active script context.

CreateObject ( ) : JavaScriptValue

Creates a new Object.

Requires an active script context.

CreateRangeError ( JavaScriptValue message ) : JavaScriptValue

Creates a new JavaScript RangeError error object

Requires an active script context.

CreateReferenceError ( JavaScriptValue message ) : JavaScriptValue

Creates a new JavaScript ReferenceError error object

Requires an active script context.

CreateSyntaxError ( JavaScriptValue message ) : JavaScriptValue

Creates a new JavaScript SyntaxError error object

Requires an active script context.

CreateTypeError ( JavaScriptValue message ) : JavaScriptValue

Creates a new JavaScript TypeError error object

Requires an active script context.

CreateUriError ( JavaScriptValue message ) : JavaScriptValue

Creates a new JavaScript URIError error object

Requires an active script context.

DefineProperty ( JavaScriptPropertyId propertyId, JavaScriptValue propertyDescriptor ) : bool

Defines a new object's own property from a property descriptor.

Requires an active script context.

DeleteIndexedProperty ( JavaScriptValue index ) : void

Delete the value at the specified index of an object.

Requires an active script context.

DeleteProperty ( JavaScriptPropertyId propertyId, bool useStrictRules ) : JavaScriptValue

Deletes an object's property.

Requires an active script context.

Equals ( JavaScriptValue other ) : bool

Compare two JavaScript values for equality.

This function is equivalent to the "==" operator in JavaScript.

Requires an active script context.

FromBoolean ( bool value ) : JavaScriptValue

Creates a Boolean value from a bool value.

Requires an active script context.

FromDouble ( double value ) : JavaScriptValue

Creates a Number value from a double value.

Requires an active script context.

FromInt32 ( int value ) : JavaScriptValue

Creates a Number value from a int value.

Requires an active script context.

FromObject ( object value ) : JavaScriptValue

Creates a JavaScript value that is a projection of the passed in object.

Requires an active script context.

FromString ( string value ) : JavaScriptValue

Creates a String value from a string pointer.

Requires an active script context.

GetIndexedProperty ( JavaScriptValue index ) : JavaScriptValue

Retrieve the value at the specified index of an object.

Requires an active script context.

GetOwnPropertyDescriptor ( JavaScriptPropertyId propertyId ) : JavaScriptValue

Gets a property descriptor for an object's own property.

Requires an active script context.

GetOwnPropertyNames ( ) : JavaScriptValue

Gets the list of all properties on the object.

Requires an active script context.

GetProperty ( JavaScriptPropertyId id ) : JavaScriptValue

Gets an object's property.

Requires an active script context.

HasIndexedProperty ( JavaScriptValue index ) : bool

Test if an object has a value at the specified index.

Requires an active script context.

HasProperty ( JavaScriptPropertyId propertyId ) : bool

Determines whether an object has a property.

Requires an active script context.

PreventExtension ( ) : void

Sets an object to not be extensible.

Requires an active script context.

Release ( ) : uint

Releases a reference to the object.

Removes a reference that was created by AddRef.

SetIndexedProperty ( JavaScriptValue index, JavaScriptValue value ) : void

Set the value at the specified index of an object.

Requires an active script context.

SetProperty ( JavaScriptPropertyId id, JavaScriptValue value, bool useStrictRules ) : void

Sets an object's property.

Requires an active script context.

StrictEquals ( JavaScriptValue other ) : bool

Compare two JavaScript values for strict equality.

This function is equivalent to the "===" operator in JavaScript.

Requires an active script context.

ToBoolean ( ) : bool

Retrieves the bool value of a Boolean value.

Requires an active script context.

ToDouble ( ) : double

Retrieves the double value of a Number value.

This function retrieves the value of a Number value. It will fail with InvalidArgument if the type of the value is not Number.

Requires an active script context.

ToObject ( ) : object

Retrieves the object representation of an Object value.

Requires an active script context.

ToString ( ) : string

Retrieves the string pointer of a String value.

This function retrieves the string pointer of a String value. It will fail with InvalidArgument if the type of the value is not String.

Requires an active script context.

Private Methods

Method Description
JavaScriptValue ( IntPtr reference ) : System

Initializes a new instance of the JavaScriptValue struct.

Method Details

AddRef() public method

Adds a reference to the object.
This only needs to be called on objects that are not going to be stored somewhere on the stack. Calling AddRef ensures that the JavaScript object the value refers to will not be freed until Release is called
public AddRef ( ) : uint
return uint

CallFunction() public method

Invokes a function.
Requires an active script context.
public CallFunction ( ) : JavaScriptValue
return JavaScriptValue

ConstructObject() public method

Invokes a function as a constructor.
Requires an active script context.
public ConstructObject ( ) : JavaScriptValue
return JavaScriptValue

ConvertToBoolean() public method

Converts the value to Boolean using regular JavaScript semantics.
Requires an active script context.
public ConvertToBoolean ( ) : JavaScriptValue
return JavaScriptValue

ConvertToNumber() public method

Converts the value to Number using regular JavaScript semantics.
Requires an active script context.
public ConvertToNumber ( ) : JavaScriptValue
return JavaScriptValue

ConvertToObject() public method

Converts the value to Object using regular JavaScript semantics.
Requires an active script context.
public ConvertToObject ( ) : JavaScriptValue
return JavaScriptValue

ConvertToString() public method

Converts the value to String using regular JavaScript semantics.
Requires an active script context.
public ConvertToString ( ) : JavaScriptValue
return JavaScriptValue

CreateArray() public static method

Creates a JavaScript array object.
Requires an active script context.
public static CreateArray ( uint length ) : JavaScriptValue
length uint The initial length of the array.
return JavaScriptValue

CreateError() public static method

Creates a new JavaScript error object
Requires an active script context.
public static CreateError ( JavaScriptValue message ) : JavaScriptValue
message JavaScriptValue Message for the error object.
return JavaScriptValue

CreateExternalObject() public static method

Creates a new Object that stores some external data.
Requires an active script context.
public static CreateExternalObject ( IntPtr data, JavaScriptObjectFinalizeCallback finalizer ) : JavaScriptValue
data System.IntPtr External data that the object will represent. May be null.
finalizer JavaScriptObjectFinalizeCallback /// A callback for when the object is finalized. May be null. ///
return JavaScriptValue

CreateFunction() public static method

Creates a new JavaScript function.
Requires an active script context.
public static CreateFunction ( JavaScriptNativeFunction function ) : JavaScriptValue
function JavaScriptNativeFunction The method to call when the function is invoked.
return JavaScriptValue

CreateFunction() public static method

Creates a new JavaScript function.
Requires an active script context.
public static CreateFunction ( JavaScriptNativeFunction function, IntPtr callbackData ) : JavaScriptValue
function JavaScriptNativeFunction The method to call when the function is invoked.
callbackData System.IntPtr Data to be provided to all function callbacks.
return JavaScriptValue

CreateObject() public static method

Creates a new Object.
Requires an active script context.
public static CreateObject ( ) : JavaScriptValue
return JavaScriptValue

CreateRangeError() public static method

Creates a new JavaScript RangeError error object
Requires an active script context.
public static CreateRangeError ( JavaScriptValue message ) : JavaScriptValue
message JavaScriptValue Message for the error object.
return JavaScriptValue

CreateReferenceError() public static method

Creates a new JavaScript ReferenceError error object
Requires an active script context.
public static CreateReferenceError ( JavaScriptValue message ) : JavaScriptValue
message JavaScriptValue Message for the error object.
return JavaScriptValue

CreateSyntaxError() public static method

Creates a new JavaScript SyntaxError error object
Requires an active script context.
public static CreateSyntaxError ( JavaScriptValue message ) : JavaScriptValue
message JavaScriptValue Message for the error object.
return JavaScriptValue

CreateTypeError() public static method

Creates a new JavaScript TypeError error object
Requires an active script context.
public static CreateTypeError ( JavaScriptValue message ) : JavaScriptValue
message JavaScriptValue Message for the error object.
return JavaScriptValue

CreateUriError() public static method

Creates a new JavaScript URIError error object
Requires an active script context.
public static CreateUriError ( JavaScriptValue message ) : JavaScriptValue
message JavaScriptValue Message for the error object.
return JavaScriptValue

DefineProperty() public method

Defines a new object's own property from a property descriptor.
Requires an active script context.
public DefineProperty ( JavaScriptPropertyId propertyId, JavaScriptValue propertyDescriptor ) : bool
propertyId JavaScriptPropertyId The ID of the property.
propertyDescriptor JavaScriptValue The property descriptor.
return bool

DeleteIndexedProperty() public method

Delete the value at the specified index of an object.
Requires an active script context.
public DeleteIndexedProperty ( JavaScriptValue index ) : void
index JavaScriptValue The index to delete.
return void

DeleteProperty() public method

Deletes an object's property.
Requires an active script context.
public DeleteProperty ( JavaScriptPropertyId propertyId, bool useStrictRules ) : JavaScriptValue
propertyId JavaScriptPropertyId The ID of the property.
useStrictRules bool The property set should follow strict mode rules.
return JavaScriptValue

Equals() public method

Compare two JavaScript values for equality.

This function is equivalent to the "==" operator in JavaScript.

Requires an active script context.

public Equals ( JavaScriptValue other ) : bool
other JavaScriptValue The object to compare.
return bool

FromBoolean() public static method

Creates a Boolean value from a bool value.
Requires an active script context.
public static FromBoolean ( bool value ) : JavaScriptValue
value bool The value to be converted.
return JavaScriptValue

FromDouble() public static method

Creates a Number value from a double value.
Requires an active script context.
public static FromDouble ( double value ) : JavaScriptValue
value double The value to be converted.
return JavaScriptValue

FromInt32() public static method

Creates a Number value from a int value.
Requires an active script context.
public static FromInt32 ( int value ) : JavaScriptValue
value int The value to be converted.
return JavaScriptValue

FromObject() public static method

Creates a JavaScript value that is a projection of the passed in object.
Requires an active script context.
public static FromObject ( object value ) : JavaScriptValue
value object An object to be projected.
return JavaScriptValue

FromString() public static method

Creates a String value from a string pointer.
Requires an active script context.
public static FromString ( string value ) : JavaScriptValue
value string The string to convert to a String value.
return JavaScriptValue

GetIndexedProperty() public method

Retrieve the value at the specified index of an object.
Requires an active script context.
public GetIndexedProperty ( JavaScriptValue index ) : JavaScriptValue
index JavaScriptValue The index to retrieve.
return JavaScriptValue

GetOwnPropertyDescriptor() public method

Gets a property descriptor for an object's own property.
Requires an active script context.
public GetOwnPropertyDescriptor ( JavaScriptPropertyId propertyId ) : JavaScriptValue
propertyId JavaScriptPropertyId The ID of the property.
return JavaScriptValue

GetOwnPropertyNames() public method

Gets the list of all properties on the object.
Requires an active script context.
public GetOwnPropertyNames ( ) : JavaScriptValue
return JavaScriptValue

GetProperty() public method

Gets an object's property.
Requires an active script context.
public GetProperty ( JavaScriptPropertyId id ) : JavaScriptValue
id JavaScriptPropertyId The ID of the property.
return JavaScriptValue

HasIndexedProperty() public method

Test if an object has a value at the specified index.
Requires an active script context.
public HasIndexedProperty ( JavaScriptValue index ) : bool
index JavaScriptValue The index to test.
return bool

HasProperty() public method

Determines whether an object has a property.
Requires an active script context.
public HasProperty ( JavaScriptPropertyId propertyId ) : bool
propertyId JavaScriptPropertyId The ID of the property.
return bool

PreventExtension() public method

Sets an object to not be extensible.
Requires an active script context.
public PreventExtension ( ) : void
return void

Release() public method

Releases a reference to the object.
Removes a reference that was created by AddRef.
public Release ( ) : uint
return uint

SetIndexedProperty() public method

Set the value at the specified index of an object.
Requires an active script context.
public SetIndexedProperty ( JavaScriptValue index, JavaScriptValue value ) : void
index JavaScriptValue The index to set.
value JavaScriptValue The value to set.
return void

SetProperty() public method

Sets an object's property.
Requires an active script context.
public SetProperty ( JavaScriptPropertyId id, JavaScriptValue value, bool useStrictRules ) : void
id JavaScriptPropertyId The ID of the property.
value JavaScriptValue The new value of the property.
useStrictRules bool The property set should follow strict mode rules.
return void

StrictEquals() public method

Compare two JavaScript values for strict equality.

This function is equivalent to the "===" operator in JavaScript.

Requires an active script context.

public StrictEquals ( JavaScriptValue other ) : bool
other JavaScriptValue The object to compare.
return bool

ToBoolean() public method

Retrieves the bool value of a Boolean value.
Requires an active script context.
public ToBoolean ( ) : bool
return bool

ToDouble() public method

Retrieves the double value of a Number value.

This function retrieves the value of a Number value. It will fail with InvalidArgument if the type of the value is not Number.

Requires an active script context.

public ToDouble ( ) : double
return double

ToObject() public method

Retrieves the object representation of an Object value.
Requires an active script context.
public ToObject ( ) : object
return object

ToString() public method

Retrieves the string pointer of a String value.

This function retrieves the string pointer of a String value. It will fail with InvalidArgument if the type of the value is not String.

Requires an active script context.

public ToString ( ) : string
return string