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.
- Host: GitHub
- URL: https://github.com/banane9/sharpplugins
- Owner: Banane9
- License: lgpl-2.1
- Created: 2014-06-07T09:49:55.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-05T13:29:11.000Z (almost 11 years ago)
- Last Synced: 2025-01-15T01:42:06.750Z (5 months ago)
- Language: C#
- Size: 230 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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)#####