private void HandleEvent(string eventName, object sender, EventArgs args)
{
var script = Settings.Default[eventName + "_Handler"] as string;
if (string.IsNullOrEmpty(script))
return;
var ctx = new ScriptContext {EventName = eventName, Sender = sender, Args = args, Host = this};
ScriptScope scope = _scriptHost.Engine.CreateScope();
scope.SetVariable("context", ctx);
object output;
try
{
output = _scriptHost.Engine.Execute(script, scope);
}
catch (Exception ex)
{
output = ex;
}
txtScriptOutput.AppendText("=>"
+ (output ?? "<null>")
+ Environment.NewLine);
}