确定所有插件的适当结构? [英] Determine an appropriate structure for all plugins?

查看:73
本文介绍了确定所有插件的适当结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个基于插件的应用程序,但问题是我已经制作了两个插件来运行客户的输入法列表



但我写的第三个插件只是一个客户。



问题是我有一个客户界面列表IAction运行方法考虑现在我知道如何插入一个客户来发送第三个。



一般来说,我认为自己是所有插件的结构



如何为每个插件原则创建合适的结构?





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;

            }
        }

    }


}}

推荐答案

这篇关于确定所有插件的适当结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆