ObjectValue used to implement the base type of object in ReoScript with a key/value paired property list. ExternalProperty class is an interface as property of ObjectValue, which used to import/export data between script and .NET.

Once an instance of ExternalProperty was added into ObjectValue by specifying a key as its name, when the property to be accessed, the getter and setter of ExternalProperty will be invoked.

The getter and setter of ExternalProperty are defined as below:
Func<object> getter;
Action<object> setter;

Implement ExternalProperty

Create ScriptRunningMachine:
ScriptRunningMachine srm = new ScriptRunningMachine(); 

Create an object in .NET:
ObjectValue obj = srm.CreateNewObject();
string color = "green";

obj["color"] = new ExternalProperty(
    () => { return color; },                  // getter
    (v) => { color = Convert.ToString(v); }   // setter

Add object into script:
srm["apple"] = obj;

Try to get property value in script:
alert(apple.color);        // result is green

Try to change the value:
apple.color = 'yellow';    // string 'color' in .Net will be changed

The result is:

Last edited Jan 25, 2014 at 6:20 AM by unvell, version 4