コード例 #1
0
ファイル: PluginHelper.cs プロジェクト: Guido1234/CodeLibrary
        public string GetDescription()
        {
            var _description = _plugin.GetType().GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute;

            if (_description == null)
            {
                return(string.Empty);
            }

            return(_description.Description);
        }
コード例 #2
0
        /// <summary>
        /// Registers a plugin, calling <see cref="IEditorPlugin.RegisterPlugin(IServiceRegistry)"/>.
        /// </summary>
        /// <param name="plugin"></param>
        public void Register(IEditorPlugin plugin)
        {
            if (activePlugins.ContainsKey(plugin.GetType()))
            {
                throw new InvalidOperationException($"Plugin of type '{plugin.GetType()}' is already registered.");
            }

            Logger.Debug($"Registering plugin '{plugin.GetType().FullName}'...");

            plugin.RegisterPlugin(Services);
            activePlugins.Add(plugin.GetType(), plugin);

            Logger.Info($"Registered plugin '{plugin.GetType().FullName}'.");
        }
コード例 #3
0
        public void AddPlugin(IEditorPlugin editorPlugin)
        {
            _imageList.Images.Add(editorPlugin.Name, editorPlugin.ToolboxImage.Picture);

            ListViewItem listViewItem = _listView.Items.Add(editorPlugin.Name, editorPlugin.Name);

            listViewItem.Tag = editorPlugin.GetType();
        }
コード例 #4
0
        public void AddPlugin(IEditorPlugin editorPlugin)
        {
            _imageList.Images.Add( editorPlugin.Name, editorPlugin.ToolboxImage.Picture ) ;

            ListViewItem listViewItem = _listView.Items.Add( editorPlugin.Name, editorPlugin.Name ) ;

            listViewItem.Tag = editorPlugin.GetType();
        }
コード例 #5
0
        public void Unregister(IEditorPlugin plugin)
        {
            if (!activePlugins.ContainsKey(plugin.GetType()))
            {
                throw new InvalidOperationException($"Plugin of type '{plugin.GetType()}' has not been registered.");
            }

            Logger.Debug($"Unregistering plugin '{plugin.GetType().FullName}'...");

            var rplugin = activePlugins[plugin.GetType()];

            if (plugin != rplugin)
            {
                Logger.Warning($"A different instance of plugin '{plugin.GetType()}' has been registered and unregistered. Make sure the plugin has no state.");
            }

            plugin.UnregisterPlugin(Services);
            activePlugins.Remove(plugin.GetType());

            Logger.Info($"Unregistered plugin '{plugin.GetType().FullName}'.");
        }