How to integrate into .NET Application

Run your script

03.png
Prepare script, and run it by using ScriptRunningMachine:
08.png
Result:
07.png
There are some basic features provided by ReoScript core, such as Array.
10.png
Result:
09.png
Learn more about ScriptRunningMachine and Language Specification.

Add your objects and functions into script

04.png

3 ways to add objects and functions

05.png

Proxy objects

Without modifying your existed objects, add proxy objects for .NET objects will make it available in script. There is a .NET class named 'Car' and its proxy class named 'CarProxy', the 'CarProxy' class only be used for script.

11.png

And there is a proxy class which provided for script:

12.png

Then run script:
13.png

Using ScriptVisible Attribute

Add 'ScriptVisible' attribute to class, field, property and method will make it visible to script.
14.png
this feature available since v1.4

DirectAccess mode (.NET Reflection)

No need to write anything, just enable the DirectAccess mode of ScriptRunningMachin.
15.png

Choose a way to integrate with your Application

Here are some tips that you can reference.
  • Proxy objects - Although proxy objects need to be written, but this mode has a good reliability and it is very safety. If you are planning to provide script available for your end-user then you may choose this.
  • ScriptVisible - There is a few difficult to control what objects and properties to be available in script. Consider that risk and choose this mode.
  • DirectAccess - This mode mix the world between .NET and Script, and script may become unavailable after you changed the appearance of .NET objects. So make sure that script available and choose this mode.
16.png

Setup

1. Download ReoScript binary or build source file. Add the following DLLs into reference list of your project.
Antlr3.Runtime.dll
unvell.ReoScript.dll

2. Import the following namespace
using unvell.ReoScript;

3. Create ScriptRunningMachine and run script
ScriptRunningMachine srm = new ScriptRunningMachine();
srm.Run(...);    // source can be string, file and stream

Last edited Dec 22, 2013 at 9:39 PM by unvell, version 20