Beispiel #1
0
        public async Task Execute(Action action, IExecutiveInteractionHandler handler, IEnumerable <string> parameters, CancellationToken token)
        {
            //TODO: Add default imports.
            var options = ScriptOptions.Default
                          .AddReferences(this._referencedAssemblies);

            var script = CSharpScript.Create(action.Source, options, typeof(ActionParameters));
            var errors = script.Compile();

            //TODO: Log this somehow.It should not happen since the sourcecode is checked on upload.
            if (errors.Any())
            {
                return;
            }

            await script.RunAsync(new ActionParameters(handler, parameters), (ex) =>
            {
                handler.Reply("Failed to process command: " + ex.Message);
                return(true);
            }, token);
        }
Beispiel #2
0
 public ActionParameters(IExecutiveInteractionHandler handler, IEnumerable <string> parameters)
 {
     Handler    = handler;
     Parameters = parameters;
 }