Beispiel #1
0
        /// <inheritdoc />
        public IPluginDescription ReflectPlugin(string pluginPath)
        {
            try
            {
                var archive     = PluginArchive.OpenRead(pluginPath);
                var description = CreateDescription(archive);
                _archivesByPlugin.Add(description, archive);
                return(description);
            }
            catch (Exception e)
            {
                Log.ErrorFormat("Unable to load '{0}': {1}", pluginPath, e);

                string  id;
                Version version;
                ExtractIdAndVersion(pluginPath, out id, out version);
                var description = new PluginDescription
                {
                    Id       = id,
                    Version  = version,
                    Error    = string.Format("The plugin couldn't be loaded: {0}", e.Message),
                    Plugins  = new Dictionary <Type, string>(),
                    FilePath = pluginPath
                };
                _archivesByPlugin.Add(description, new EmptyPluginArchive());
                return(description);
            }
        }
Beispiel #2
0
        /// <inheritdoc />
        public IPluginDescription ReflectPlugin(Stream stream, bool leaveOpen = false)
        {
            var archive     = PluginArchive.OpenRead(stream, leaveOpen);
            var description = CreateDescription(archive);

            _archivesByPlugin.Add(description, archive);
            return(description);
        }
Beispiel #3
0
        public PluginGroup OpenPlugin(string pluginPath)
        {
            var stream = _filesystem.OpenRead(pluginPath);

            try
            {
                // Ownership of the stream transfers to PluginArchive which is disposed of when this class is
                // disposed of....
                var archive = PluginArchive.OpenRead(stream);
                return(Add(pluginPath, archive));
            }
            catch (Exception)
            {
                stream.Dispose();
                throw;
            }
        }
Beispiel #4
0
        /// <summary>
        ///     Tries to open the file at the given path as a tailviewer plugin.
        ///     Succeeds if the file is a zip archive and its metadata could be read.
        ///     The plugin itself is not loaded until later.
        /// </summary>
        /// <param name="pluginPath"></param>
        private void TryOpenPlugin(string pluginPath)
        {
            Log.DebugFormat("Loading plugin '{0}'...", pluginPath);

            ExtractIdAndVersion(pluginPath, out var id, out var version);
            try
            {
                // DO NOT DISPOSE OF THE STREAM HERE!!!
                // Ownership transfers to PluginArchive which is disposed of when this class is
                // disposed of....
                var stream  = _filesystem.OpenRead(pluginPath).Result;
                var archive = PluginArchive.OpenRead(stream);
                Add(pluginPath, id, version, archive);
            }
            catch (Exception e)
            {
                Log.ErrorFormat("Unable to load '{0}': {1}", pluginPath, e);
                Add(pluginPath, id, version, new EmptyPluginArchive(version));
            }
        }
        public IPluginDescription ReflectPlugin(Stream stream, bool leaveOpen = false)
        {
            var archive = PluginArchive.OpenRead(stream, leaveOpen);

            return(ReflectPlugin(archive));
        }