Skip to content
Jing Lu edited this page May 14, 2013 · 22 revisions

ObjectValue is a class to implement the type of object in ReoScript. ObjectValue has a property list with key/value pairs.

When an object created in script, the ScriptRunningMachine will create an ObjectValue instance in C#.

ReoScript:

var obj = new Object();    // using Object constructor
var obj = {};              // using JSON literal

C#:

ObjectValue obj = new ObjectValue();

Using object in script

var apple = new Object();

Set or get property value:

apple.color = 'red';  // set
var a = apple.color;  // get

Or create object with standard JavaScript/ECMAScript object literal syntax:

var apple = { name: 'apple', color: 'red' };

Use object in .Net program

You may create objects in .Net program, the objects are also available to script.

ScriptRunningMachine srm = new ScriptRunningMachine();

ObjectValue obj = srm.CreateNewObject();
obj["name"] = "apple";
obj["color"] = "red";

srm["apple"] = obj;

Run script to output property value:

ReoScript:

alert(apple.color);   // result is red

The result is:

ObjectValue

Add method into object in .Net program

To add method into object in .Net program, see NativeFunctionObject.

See Also

Clone this wiki locally