Ejemplo n.º 1
0
        public string GetVersion(string pluginId)
        {
            var plugin = _pluginEngine.Get(pluginId);

            if (plugin == null)
            {
                return(null);
            }

            return(plugin.Package.Version.ToString());
        }
Ejemplo n.º 2
0
        public void Handle(PluginErrorMessage message)
        {
            var failedPlugin = _pluginEngine.Get(message.PluginId);

            if (failedPlugin == null)
            {
                return;
            }

            var unloadOrder = _pluginEngine.GetUnloadOrder(message.PluginId);

            foreach (var pluginId in unloadOrder)
            {
                _pluginEngine.Unload(pluginId);
            }

            if (failedPlugin.ErrorCount >= MaxErrorCount)
            {
                _logger.Error("Plugin {PluginId} has failed {ErrorCount} or more times. Not reloading.", message.PluginId, MaxErrorCount);
                return;
            }

            foreach (var pluginId in unloadOrder.Reverse())
            {
                _pluginEngine.Load(pluginId);
            }
        }
Ejemplo n.º 3
0
        public PluginsModule(IPluginEngine pluginEngine, IJsonRpcClient rpcClient)
            : base("plugins")
        {
            Get["/{id}/{path*}"] = _ =>
            {
                string id   = _.id;
                string path = _.path;

                var plugin = pluginEngine.Get(id);
                if (plugin == null)
                {
                    return(404);
                }

                var data = rpcClient.Call <byte[]>(string.Format("{0}.resource.get", id), new[] { path });
                if (data == null)
                {
                    return(404);
                }

                var contentType = MimeTypes.GetMimeType(path);
                return(Response.FromStream(() => new MemoryStream(data), contentType));
            };
        }
Ejemplo n.º 4
0
        public PluginsModule(IPluginEngine pluginEngine, IJsonRpcClient rpcClient)
            : base("plugins")
        {
            Get["/{id}/{path*}"] = _ =>
            {
                string id = _.id;
                string path = _.path;

                var plugin = pluginEngine.Get(id);
                if (plugin == null)
                {
                    return 404;
                }

                var data = rpcClient.Call<byte[]>(string.Format("{0}.resource.get", id), new[] {path});
                if (data == null)
                {
                    return 404;
                }

                var contentType = MimeTypes.GetMimeType(path);
                return Response.FromStream(() => new MemoryStream(data), contentType);
            };
        }