DotNetBrowser  1.14
Public Member Functions | Static Public Member Functions | List of all members
DotNetBrowser.JSValue Class Reference

Class for all JavaScript values. This class is used to store the result of the Browser.ExecuteJavaScript(string) method execution. More...

Inherited by DotNetBrowser.JSNull, DotNetBrowser.JSObject, DotNetBrowser.JSPrimitive< T >, and DotNetBrowser.JSUndefined.

Public Member Functions

virtual bool IsUndefined ()
 Indicates whether JavaScript value is undefined. More...
 
virtual bool IsObject ()
 Indicates whether JavaScript value is an object. If this method returns true, then the value can be casted to JSObject type. For example: More...
 
virtual bool IsFunction ()
 Indicates whether JavaScript value is a function. If this method returns true, then the value can be casted to JSFunction type. For example: More...
 
virtual bool IsNull ()
 Indicates whether JavaScript value is NULL. More...
 
bool IsTrue ()
 Indicates whether JavaScript value represents bool TRUE value. More...
 
bool IsFalse ()
 Indicates whether JavaScript value represents bool FALSE value. More...
 
virtual bool IsString ()
 Indicates whether JavaScript value is a string. If this method returns true, then the value can be casted to JSString type. For example: More...
 
virtual bool IsJSON ()
 Indicates whether JavaScript value is a string in JSON format. More...
 
virtual bool IsBool ()
 Indicates whether JavaScript value is a boolean value. If this method returns true, then the value can be casted to JSBoolean type. For example: More...
 
virtual bool IsNumber ()
 Indicates whether JavaScript value is a number value which equals to double type. If this method returns true, then the value can be casted to JSNumber type. For example: More...
 
virtual bool IsArray ()
 Indicates whether JavaScript value is an array. If this method returns true, then the value can be casted to JSArray type. For example: More...
 
virtual bool IsBooleanObject ()
 Indicates whether JavaScript value is a JSBoolean object. If this method returns true, then the value can be casted to JSBooleanObject type. For example: More...
 
virtual bool IsNumberObject ()
 Indicates whether JavaScript value is a Number object. If this method returns true, then the value can be casted to JSNumberObject type. For example: More...
 
virtual bool IsStringObject ()
 Indicates whether JavaScript value is a String object. If this method returns true, then the value can be casted to JSStringObject type. For example: More...
 
virtual bool IsDotNetObject ()
 Indicates whether JavaScript value is a .Net object. If this method returns true, then the value can be casted to Object type. For example: More...
 
virtual JSBoolean AsBoolean ()
 Casts the current JavaScript object to JSBoolean type. If the current object doesn't represent a Boolean object, the InvalidCastException error is thrown. More...
 
virtual JSFunction AsFunction ()
 Casts the current JavaScript object to JSFunction type. If the current object doesn't represent a function, the InvalidCastException error is thrown. More...
 
virtual JSBooleanObject AsBooleanObject ()
 Casts the current JavaScript object to JSBooleanObject type. If the current object doesn't represent a Boolean object, the InvalidCastException error is thrown. More...
 
virtual JSNumber AsNumber ()
 Casts the current JavaScript object to JSNumber type. If the current object doesn't represent a number value, the InvalidCastException error is thrown. More...
 
virtual JSNumberObject AsNumberObject ()
 Casts the current JavaScript object to JSNumberObject type. If the current object doesn't represent a Number object, the InvalidCastException error is thrown. More...
 
virtual JSArray AsArray ()
 Casts the current JavaScript object to JSArray type. If the current object doesn't represent an array, the InvalidCastException error is thrown. More...
 
virtual JSObject AsObject ()
 Casts the current JavaScript object to JSObject type. If the current object doesn't represent an object (e.g. it's a primitive value), the InvalidCastException error is thrown. More...
 
virtual JSString AsString ()
 Casts the current JavaScript object to JSString type. If the current object doesn't represent a string value, the InvalidCastException error is thrown. More...
 
virtual JSStringObject AsStringObject ()
 Casts the current JavaScript object to JSStringObject type. If the current object doesn't represent a String object, the InvalidCastException error is thrown. More...
 
virtual object AsDotNetObject ()
 Casts the current JavaScript object to Object type. If the current object doesn't represent a .Net object, the InvalidCastException error is thrown. More...
 
virtual bool GetBool ()
 Returns boolean value of the current JavaScript object if object represents a primitive boolean or Boolean object, otherwise throws InvalidOperationException. More...
 
virtual double GetNumber ()
 Returns number value of the current JavaScript object if object represents a primitive number or Number object, otherwise throws InvalidOperationException. More...
 
virtual string GetString ()
 Returns string value of the current JavaScript object if object represents a primitive string or String object, otherwise throws InvalidOperationException. More...
 

Static Public Member Functions

static JSValue Create (double value)
 Creates double JSValue instance. More...
 
static JSValue Create (bool value)
 Creates boolean JSValue instance. More...
 
static JSValue CreateUndefined ()
 Creates undefined JSValue instance. More...
 
static JSValue Create (string value)
 Creates string JSValue instance. More...
 
static JSONString CreateJSON (string jsonString)
 Creates JavaScript value that represents a string in JSON format. When this value is passed to JavaScript side, it will be automatically parsed and converted to appropriate JavaScript object. More...
 
static JSValue CreateNull ()
 Creates null JSValue instance. More...
 

Detailed Description

Class for all JavaScript values. This class is used to store the result of the Browser.ExecuteJavaScript(string) method execution.

Member Function Documentation

virtual JSArray DotNetBrowser.JSValue.AsArray ( )
virtual

Casts the current JavaScript object to JSArray type. If the current object doesn't represent an array, the InvalidCastException error is thrown.

Exceptions
InvalidCastExceptionwhen current object doesn't represent an array.

Reimplemented in DotNetBrowser.JSArray.

virtual JSBoolean DotNetBrowser.JSValue.AsBoolean ( )
virtual

Casts the current JavaScript object to JSBoolean type. If the current object doesn't represent a Boolean object, the InvalidCastException error is thrown.

Exceptions
InvalidCastExceptionwhen current object doesn't represent a JSBoolean object.
virtual JSBooleanObject DotNetBrowser.JSValue.AsBooleanObject ( )
virtual

Casts the current JavaScript object to JSBooleanObject type. If the current object doesn't represent a Boolean object, the InvalidCastException error is thrown.

Exceptions
InvalidCastExceptionwhen current object doesn't represent a Boolean object.

Reimplemented in DotNetBrowser.JSBooleanObject.

virtual object DotNetBrowser.JSValue.AsDotNetObject ( )
virtual

Casts the current JavaScript object to Object type. If the current object doesn't represent a .Net object, the InvalidCastException error is thrown.

Exceptions
InvalidCastExceptionwhen current object doesn't represent a .Net object.

Reimplemented in DotNetBrowser.JSObject.

virtual JSFunction DotNetBrowser.JSValue.AsFunction ( )
virtual

Casts the current JavaScript object to JSFunction type. If the current object doesn't represent a function, the InvalidCastException error is thrown.

Exceptions
InvalidCastExceptionwhen current object doesn't represent a function.

Reimplemented in DotNetBrowser.JSFunction.

virtual JSNumber DotNetBrowser.JSValue.AsNumber ( )
virtual

Casts the current JavaScript object to JSNumber type. If the current object doesn't represent a number value, the InvalidCastException error is thrown.

Returns
virtual JSNumberObject DotNetBrowser.JSValue.AsNumberObject ( )
virtual

Casts the current JavaScript object to JSNumberObject type. If the current object doesn't represent a Number object, the InvalidCastException error is thrown.

Exceptions
InvalidCastExceptionwhen current object doesn't represent a Number object.

Reimplemented in DotNetBrowser.JSNumberObject.

virtual JSObject DotNetBrowser.JSValue.AsObject ( )
virtual

Casts the current JavaScript object to JSObject type. If the current object doesn't represent an object (e.g. it's a primitive value), the InvalidCastException error is thrown.

Exceptions
InvalidCastExceptionwhen current object doesn't represent an Object.

Reimplemented in DotNetBrowser.JSObject.

virtual JSString DotNetBrowser.JSValue.AsString ( )
virtual

Casts the current JavaScript object to JSString type. If the current object doesn't represent a string value, the InvalidCastException error is thrown.

Exceptions
InvalidCastExceptionwhen current object doesn't represent a string value.
virtual JSStringObject DotNetBrowser.JSValue.AsStringObject ( )
virtual

Casts the current JavaScript object to JSStringObject type. If the current object doesn't represent a String object, the InvalidCastException error is thrown.

Exceptions
InvalidCastExceptionwhen current object doesn't represent a String object.

Reimplemented in DotNetBrowser.JSStringObject.

static JSValue DotNetBrowser.JSValue.Create ( double  value)
static

Creates double JSValue instance.

Parameters
valueDouble value.
Returns
Double JSValue instance.
static JSValue DotNetBrowser.JSValue.Create ( bool  value)
static

Creates boolean JSValue instance.

Parameters
valueBoolean value.
Returns
Boolean JSValue instance.
static JSValue DotNetBrowser.JSValue.Create ( string  value)
static

Creates string JSValue instance.

Parameters
valueString value.
Returns
String JSValue instance.
static JSONString DotNetBrowser.JSValue.CreateJSON ( string  jsonString)
static

Creates JavaScript value that represents a string in JSON format. When this value is passed to JavaScript side, it will be automatically parsed and converted to appropriate JavaScript object.

Parameters
jsonStringstring in JSON format.
Returns
JavaScript value that represents a string in JSON format.
static JSValue DotNetBrowser.JSValue.CreateNull ( )
static

Creates null JSValue instance.

Returns
null JSValue instance.
static JSValue DotNetBrowser.JSValue.CreateUndefined ( )
static

Creates undefined JSValue instance.

Returns
Undefined JSValue instance.
virtual bool DotNetBrowser.JSValue.GetBool ( )
virtual

Returns boolean value of the current JavaScript object if object represents a primitive boolean or Boolean object, otherwise throws InvalidOperationException.

Returns
value of JavaScript bool value.
Exceptions
InvalidOperationExceptionwhen current JavaScript object doesn't represent a primitive boolean or Boolean object.

Reimplemented in DotNetBrowser.JSBooleanObject.

virtual double DotNetBrowser.JSValue.GetNumber ( )
virtual

Returns number value of the current JavaScript object if object represents a primitive number or Number object, otherwise throws InvalidOperationException.

Returns
value of the current JavaScript object if object represents a primitive number or Number object.
Exceptions
InvalidOperationExceptionwhen current JavaScript object doesn't represent a primitive number or Number object.

Reimplemented in DotNetBrowser.JSNumberObject.

virtual string DotNetBrowser.JSValue.GetString ( )
virtual

Returns string value of the current JavaScript object if object represents a primitive string or String object, otherwise throws InvalidOperationException.

Returns
string value of the current JavaScript object if object represents a primitive string or String object.
Exceptions
InvalidOperationExceptionwhen current JavaScript object doesn't represent a primitive string or String object.

Reimplemented in DotNetBrowser.JSStringObject.

virtual bool DotNetBrowser.JSValue.IsArray ( )
virtual

Indicates whether JavaScript value is an array. If this method returns true, then the value can be casted to JSArray type. For example:

if (value.IsArray()) { JSArray array = value.AsArray(); }

Returns
true when JavaScript value is an array.

Reimplemented in DotNetBrowser.JSArray.

virtual bool DotNetBrowser.JSValue.IsBool ( )
virtual

Indicates whether JavaScript value is a boolean value. If this method returns true, then the value can be casted to JSBoolean type. For example:

if (value.IsBool()) { JSBoolean bool = value.AsBoolean(); }

Returns
true when JavaScript value is a Bool object.
virtual bool DotNetBrowser.JSValue.IsBooleanObject ( )
virtual

Indicates whether JavaScript value is a JSBoolean object. If this method returns true, then the value can be casted to JSBooleanObject type. For example:

if (value.IsBooleanObject()) { JSBooleanObject booleanObject = value.AsBooleanObject(); }

Returns
true when JavaScript value is a JSBoolean object.

Reimplemented in DotNetBrowser.JSBooleanObject.

virtual bool DotNetBrowser.JSValue.IsDotNetObject ( )
virtual

Indicates whether JavaScript value is a .Net object. If this method returns true, then the value can be casted to Object type. For example:

        if (value.IsDotNetObject()) {
        Object object = value.AsDotNetObject();
        }
    
Returns
true when JavaScript value is an .Net object.

Reimplemented in DotNetBrowser.JSObject.

bool DotNetBrowser.JSValue.IsFalse ( )

Indicates whether JavaScript value represents bool FALSE value.

Returns
true when JavaScript value represents bool FALSE value.
Exceptions
InvalidOperationExceptionwhen current JavaScript object doesn't represent a primitive boolean or Boolean object.
virtual bool DotNetBrowser.JSValue.IsFunction ( )
virtual

Indicates whether JavaScript value is a function. If this method returns true, then the value can be casted to JSFunction type. For example:

if (value.IsFunction()) { JSFunction function = value.AsFunction(); }

Returns
true when JavaScript value is an function.

Reimplemented in DotNetBrowser.JSFunction.

virtual bool DotNetBrowser.JSValue.IsJSON ( )
virtual

Indicates whether JavaScript value is a string in JSON format.

Returns
true when JavaScript value is a string in JSON format.
virtual bool DotNetBrowser.JSValue.IsNull ( )
virtual

Indicates whether JavaScript value is NULL.

Returns
true when JavaScript value is NULL.

Reimplemented in DotNetBrowser.JSNull.

virtual bool DotNetBrowser.JSValue.IsNumber ( )
virtual

Indicates whether JavaScript value is a number value which equals to double type. If this method returns true, then the value can be casted to JSNumber type. For example:

if (value.IsNumber()) { JSNumber number = value.AsNumber(); }

Returns
true when JavaScript value is a number value.
virtual bool DotNetBrowser.JSValue.IsNumberObject ( )
virtual

Indicates whether JavaScript value is a Number object. If this method returns true, then the value can be casted to JSNumberObject type. For example:

if (value.IsNumberObject()) { JSNumberObject numberObject = value.AsNumberObject(); }

Returns
true when JavaScript value is a Number object.

Reimplemented in DotNetBrowser.JSNumberObject.

virtual bool DotNetBrowser.JSValue.IsObject ( )
virtual

Indicates whether JavaScript value is an object. If this method returns true, then the value can be casted to JSObject type. For example:

if (value.IsObject()) { JSObject object = value.AsObject(); }

Returns
true when JavaScript value is an object.

Reimplemented in DotNetBrowser.JSObject.

virtual bool DotNetBrowser.JSValue.IsString ( )
virtual

Indicates whether JavaScript value is a string. If this method returns true, then the value can be casted to JSString type. For example:

if (value.IsString()) { JSString string = value.AsString(); }

Returns
true when JavaScript value is a string.
virtual bool DotNetBrowser.JSValue.IsStringObject ( )
virtual

Indicates whether JavaScript value is a String object. If this method returns true, then the value can be casted to JSStringObject type. For example:

if (value.isStringObject()) { JSStringObject stringObject = value.asStringObject(); }

Returns
true when JavaScript value is a String object.

Reimplemented in DotNetBrowser.JSStringObject.

bool DotNetBrowser.JSValue.IsTrue ( )

Indicates whether JavaScript value represents bool TRUE value.

Returns
true when JavaScript value represents bool TRUE value.
Exceptions
InvalidOperationExceptionwhen current JavaScript object doesn't represent a primitive boolean or Boolean object.
virtual bool DotNetBrowser.JSValue.IsUndefined ( )
virtual

Indicates whether JavaScript value is undefined.

Returns
true when JavaScript value is undefined.

Reimplemented in DotNetBrowser.JSUndefined.