Knowing that I can add global instances of host objects to the script engine like this:
E.g. something like:
engine.AddHostObject("random", new Random());
engine.Execute("Console.WriteLine(random.NextDouble())");
I wonder whether it would be possible to directly introduce global functions to the script engine so that I could directly execute this function in my script without specifying an object.E.g. something like:
engine.AddHostFunction("add", delegate(int a, int b) { return a + b });
engine.Execute("Console.WriteLine(add(1,2))");
Does this sound reasonable? Is this possible?