Exemple #1
0
        static void Main()
        {
            var srm = new ScriptRunningMachine();

            srm.AllowDirectAccess = true;

            // proxy mode
            srm.ImportType(typeof(CarProxy), "Car1");

            // attribute mode
            srm.ImportType(typeof(Car2), "Car2");

            // DirectAccess mode
            srm.ImportType(typeof(Car), "Car3");

            srm.Run(@"

var car1 = new Car1();
car1.forward();

var car2 = new Car2();
car2.forward();

var car3 = new Car3();
car3.forward();

");
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // enable DirectAccess
            srm.WorkMode |= MachineWorkMode.AllowDirectAccess;

            // import type LinkLabel
            srm.ImportType(typeof(LinkLabel));

            // add sandbox instance as global variable
            srm.SetGlobalVariable("sandbox", sandboxGroup);


            txtScript.Text = @"
sandbox.controls.add(
  new LinkLabel(){ text: 'Link added!', dock: 'Fill' }
);
";
            btnRun.Click  += (ss, ee) => { srm.Run(txtScript.Text); };
        }
Exemple #3
0
 public void LoadModule(ScriptRunningMachine srm)
 {
     srm.ImportType(typeof(FileConstructorFunction), "File");
     srm.ImportType(typeof(DirectoryConstructorFunction), "Directory");
 }