Have you ever thought about including a scripting engine into your application? Maybe for advanced users, or just to be able to automate some things?
Goals of a Scripting Language
So what do you expect from an scripting engine?
First of all, you want it to be simple but it should also be powerful. Experienced users should get the chance of performing advanced tasks.
Most builtin scripting languages also provide their own command set, e.g. Read/Write application configuration without parsing any file.
As we are developing in the .NET world, all this cries for using a CLR Language as scripting language, but there remains one problem.
How to Achieve Simplicity
Imagine someone just wants to output some lines to the console:
public class Test
{
static void main(string[] args)
{
Console.WriteLine("myText");
}
}
That's definitely not what I would call simple!
What Do We Need to Make this Simpler?
My idea of solving this situation works as follows:
- Eliminate the need to write class and method definitions
Just write:
Console.WriteLine("myText");
This will be automatically embedded into a class and method definition.
- Provide the possibility to include user written methods and classes
For simple tasks, the overhead is minimized and more advanced users can still show what they can. ;-)
- Provide the possibility to register custom methods and properties
They are directly usable from the user script. See TestEnvironment
of DevEck.ScriptingEngine
.
Check Out the Scripting Engine and Example Application
I implemented the mentioned things and attached the library with a simple test projects. The test project accepts VB.NET code, but you can switch to C#. I currently use it in a highly database enabled application for automating SQL Queries.
If you like it, please leave me a comment.
Update 14.01.2010