Is this possible
CS Code:
using RemObjects.Script;
using RemObjects.Script.EcmaScript;
using System;
using System.Reflection;
namespace ToRemObjects
{
class TestClass
{
public void exo() { }
}
class Program
{
static EcmaScriptComponent esc;
static ExecutionContext eContext_1;
static ExecutionContext eContext_2;
static Program()
{
esc = new EcmaScriptComponent();
// load script engine with base resources
esc.Include("BigScriptLib", "e:\\...\\lib.js");
esc.ExposeType(typeof(TestClass), typeof(TestClass).Name);
}
static void Main(string[] args)
{
// scripts are only for example of problem which I want to eliminate
//
// scripts written by user 1
string context_0_script_1 = @"var gVar_1 = 10";
string context_0_script_2 = @"
var gVar_2 = gVar_1*10;
var d = new TestClass();
d.exo();// this is only for example of base resources sharing between context
";
// scripts written by user 2 which do not now nothing about above scripts
// he not deliberately used name gVar_1
string context_1_script_1 = @"var gVar_1 = 3";
string context_1_script_2 = @"var gVar_4 = gVar_1*10";
// this is now how I do things, and this is logical sequence of execution
esc.RunFunction("eval", context_0_script_1);
esc.RunFunction("eval", context_1_script_1);
esc.RunFunction("eval", context_0_script_2);
esc.RunFunction("eval", context_1_script_2);
// this is what I want to achieve
var eContext_0 = new ExecutionContext(...);
var eContext_1 = new ExecutionContext(...);
esc.RootContext = eContext_0;
esc.RunFunction("eval", context_0_script_1);
esc.RootContext = eContext_1;
esc.RunFunction("eval", context_1_script_1);
esc.RootContext = eContext_0;
esc.RunFunction("eval", context_0_script_2);
esc.RootContext = eContext_1;
esc.RunFunction("eval", context_1_script_2);
}
}
}