Simple library for load plugins
Create your interface for plugin:
namespace PluginContract
{
public interface IPlugin
{
void DoSomething();
}
}
Create you own implementation of plugin (basically it should be separate Assembly):
using PluginContract;
namespace PluginAssembly
{
public class Plugin : IPlugin
{
public void DoSomething()
{
// Your implementation here.
}
}
}
When you need to load plugins in your code:
using PluginContract;
// Include PluginsLoader library.
using PluginsLoader;
namespace PluginUsage
{
public class PluginsConsumer
{
public void Test()
{
// Get plugins from specific file.
var plugins = Loader.Default.LoadFrom<IPlugin>("Plugins/MyPlugins/PluginAssembly.dll");
// Get plugins from dir.
plugins = Loader.Default.LoadFrom<IPlugin>("Plugins/MyPlugins");
// Get plugins from dir recursive.
plugins = Loader.Default.LoadFrom<IPlugin>("Plugins", true);
}
}
}