예제 #1
0
        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);
        }
예제 #2
0
        static void Main(string[] args)
        {
            //toAppStart
            var plugins = new JintPluginsStore();
            plugins.StartUpPlugins(PluginPath);

            while (true)
            {
                Transform(plugins);
                Thread.Sleep(1000);
            }
        }
예제 #3
0
        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();
            }
        }