PluginManager

Manages a collection of IPlugin objects and filters that apply to those plugins, notifying listeners about the state of plugins within the collection. It is guaranteed that all plugins in the collection will adhere to all specified filters. The PluginManager can be used independently of the Plugin and PluginHost abstract classes for managing IPlugin objects.

This class is not thread safe.

Events

public event EventHandler<PluginLoadedEventArgs> PluginLoadedEvent;
An event thrown when a plugin is loaded into the collection.

public event EventHandler<PluginUnloadedEventArgs> PluginUnloadedEvent;
An event thrown when a plugin is unloaded from the collection.

Constructors

public PluginManager()
Initializes a new instance of the PluginManager class. The filter is initialized containing the IPlugin type.

Properties

public int Count { get; }
Gets the number of elements in the collection.

Methods

public bool IsEmpty();
Resolves the status of the existence of objects in the collection. Returns true if there is an object in the collection, false otherwise.

public IPlugin GetPlugin(string key)
Gets the plugin from the collection with the provided key. Returns the plugin or null if the key is not in the collection.
  • key - The key of the plugin to get.

public void AddFilter(Type type);
Adds a required filter to the collection. Plugins loaded and currently held must support all Interface types in the filter. An ArgumentNullException is thrown when type is null. An ArgumentException is thrown when type is not an interface.
  • type - The Interface type to allow in the collection.

public void Load(string path, bool recursive);
Load an IPlugin or collection of IPlugins. A NullReferenceException is thrown when path is null. An ArgumentException is thrown when path is not a valid path to a directory or file.
  • path - The path to a directory or file.
  • recursive - Whether to recursively go through sub-directories.

public void LoadDirectory(string path, bool recursive);
Loads all IPlugins from the directory. A NullReferenceException is thrown when path is null. An ArgumentException is thrown when path is not a valid path to a directory.
  • path - The path to a directory containing DLLs.
  • recursive - Whether to recursively go through sub-directories.

public void LoadFile(string filePath);
Loads an IPlugin from the specified dynamic link library. An ArgumentNullException is thrown when filePath is null.
  • filePath - The path to a dynamic link library.

public void Unload(string key);
Removes and disposes of a plugin by key from this collection. An ArgumentNullException is thrown when the key is null.
  • key - The key of the plugin to remove.

public void Unload(IPlugin plugin);
Removes and disposes a plugin from this collection. An ArgumentNullException is thrown when plugin is null. An ArgumentException is thrown when plugin is not in the collection.
  • plugin - The plugin to remove.

public void UnloadAll()
Removes and disposes of all plugins from this collection.

Methods: Protected

protected void CallPluginLoadedEvent(IPlugin plugin);
Raises a PluginLoadedEvent for this PluginCollection. An ArgumentNullException is thrown when plugin is null.
  • plugin - The plugin that was loaded.

protected void CallPluginUnloadedEvent(IPlugin plugin);
Raises a PluginUnloadedEvent for this PluginCollection. An ArgumentNullException is thrown when plugin is null.
  • plugin - The plugin that was loaded.

Last edited Mar 19, 2013 at 5:31 PM by jsaundea, version 4

Comments

No comments yet.