I am currently evaluating scripting options for my .NET application. The user should be able to write a script (in a dedicated text/code editor within the application) to control the application itself. The application is completely written in C#. As scripting languages I am currently evaluating
- LUA
- IronPython
I found the following article (https://www.cyotek.com/blog/adding-scripting-to-net-applications) which relies on JavaScript which could also be an option. Currently it is not clear to me how I can offer my internal objects used in the application and custom functions for the used script. The link above relies on JINT (Javascript Interpreter for .NET) which offers means to add own method and objects for the script:
protected virtual void InitializeEnvironment()
{
this.AddFunction("print", new Action<object>(this.WriteLine));
this.AddFunction("log", new Action<object>(this.WriteLine));
this.AddFunction("cls", new Action(this.ClearScreen));
// interactive functions
this.AddFunction("alert", new Action<object>(this.ShowAlert));
this.AddFunction("confirm", new Func<object, bool>(this.ShowConfirm));
this.AddFunction("prompt", new Func<object, object, string>(this.ShowPrompt));
}
I didn't find means to do this with IronPython - at least it is not mentioned in the documentation and there are no examples for this kind of approach. Perhaps I am completely on the wrong track here - any help/tip would be great.
CSharpCodeProvider.NLua