public static void UsePlugins(this Engine engine, string pluginsNamespace, JintPluginsStore pluginsStore) { var instances = LoadPluginsInstances(pluginsStore.PluginsAssembliesStore).Cast<IPlugin>(); var plugObject = instances.ToDictionary(x => x.GetType().Name, x => x); engine.SetValue(pluginsNamespace, plugObject); }
static void Main(string[] args) { //toAppStart var plugins = new JintPluginsStore(); plugins.StartUpPlugins(PluginPath); while (true) { Transform(plugins); Thread.Sleep(1000); } }
private static void Transform(JintPluginsStore plugins) { var engine = new Engine(); engine.UsePlugins("ais", plugins); engine.Execute(@" function hello() { return ais.TestPlugin.Test('dsadsa'); }; "); try { var hello = engine.Invoke("hello"); Console.WriteLine(hello); } catch (TargetInvocationException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); } }