An open API service indexing awesome lists of open source software.

https://github.com/banane9/sharpplugins

Helpers for having plugins in a .NET application.
https://github.com/banane9/sharpplugins

Last synced: 4 months ago
JSON representation

Helpers for having plugins in a .NET application.

Awesome Lists containing this project

README

        

SharpPlugins
============

Helpers for having plugins in a .NET application.

-------------------------------------------------------------------------------------------------------------------------------------

##Usage##

Plugins have to be derived from `SharpPlugins.PluginBase`.

If they're supposed to be loaded, they have to be marked with the `SharpPlugins.PluginBase.RegisterPluginAttribute` and not be abstract.

The client just has to use the methods provided in the `SharpPlugins.PluginLoader` class.

###Example###

``` CSharp
using SharpPlugins;

namespace SharpPlugins.Example
{
public abstract class ApplicationPluginBase : PluginBase
{
public abstract void DoStuff();
}


[RegisterPlugin("ExamplePlugin", name: "Example Plugin", author: "Banane9")]
public class ExampleApplicationPlugin : ApplicationPluginBase
{
public override void DoStuff()
{
// Do Stuff!
}
}

internal class Program
{
private static void Main(string[] args)
{
var pluginInstance = PluginLoader.InstanciatePlugins(new Type[] { typeof(ExampleApplicationPlugin) }).First();

pluginInstance.DoStuff();
}
}
}

```

To get the Types one would use the `PluginLoader.LoadPluginsFromFiles` or `PluginLoader.LoadPluginsFromFolders` methods, but here we know the Type, so we can pass it directly to the `PluginLoader.InstanciatePlugins` method.

---------------------------------------------------------------------------------------------------------------------------------

##License##

#####[LGPL V2.1](https://github.com/Banane9/SharpPlugins/blob/master/LICENSE.md)#####