I've written a plugin-based application, but the problem I've made it up to 2 plug-ins that run the input method list of Customers take
But I write the third plugin was just a customer.
The problem is that I've got a list of "Customer" interface "IAction" Run method considered and now I know how to plugin a "Customer" to send a third.
In general, I consider myself a structure for all plugins
How to create an appropriate structure for each plug-in principle?
namespace PluginDatabase.Defention{
public interface IPlugin
{
string Name { get; }
List<IAction> Actions { get; }
}
}
namespace PluginDatabase.Defention{
public interface IAction
{
string Name { get; }
void Run(List<Customer> customers);
}
}
private void Form1_Load(object sender, EventArgs e){
int x = 250;
int y = 342;
var dlls = Directory.GetFiles(@"Plugins\", "*.dll");
foreach (var dll in dlls)
{
var asmbli = Assembly.LoadFrom(dll);
foreach (var typee in asmbli.GetTypes())
{
if (typee.GetInterface("IPlugin") != null)
{
var plugin = Activator.CreateInstance(typee) as IPlugin;
foreach (var action in plugin.Actions)
{
var actionButton = new Button();
actionButton.Text = action.Name;
actionButton.Click += (ss, ee) =>
{
action.Run(getCustomers());
};
actionButton.Location=new Point(x,y);
actionButton.Size = new Size(100, 43);
this.Controls.Add(actionButton);
x-= 110;
}
}
}
}}