基于程序插件(插件库)? [英] program plugin based (plugin base)?
问题描述
hi hi
这篇关于基于程序插件(插件库)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
我正在编写一个基于插件的程序,通常我们有一个数据库,其中包含为此项目编写的客户列表等插件应该计算传入的数据(信息),假设有4个人要为这个程序写4个插件,例如一个获得客户数量,第二个插件计算债务等等。事情是我怎样才能进入客户在界面输入中列出一个编写插件的人不会参与数据库并从界面输入中获取信息并随后完成工作
< pre lang =c#> namespace PluginBasdeApp.PluginDefenition {
public interface IPlugin
{
string 名称{ get 跨度>; }
List< IAction>操作{获取; }
}
}
namespace PluginBasdeApp.PluginDefenition {
public interface IAction
{
string 名称{ get ; }
列表<客户>运行(列出<客户>客户);
}
} 插件的一种方法是使用Microsoft MEF:
http://en.wikipedia.org/wiki/Managed_Extensibility_Framework [ ^ ],
http://mef.codeplex.com [ ^ ],
http://msdn.microsoft.com/en -us / library / dd460648%28VS.100%29.aspx [ ^ ]。
或者,您可以使用反射创建更简单的插件架构。我在过去的答案中解释了主要观点:
访问驻留在插件dll中的自定义对象 [ ^ ],
通过它的字符串表示从集合中收集类型 [ ^ ],
项目和DLL:如何保持它们可管理? [ ^ ],
现有实例上的C#Reflection InvokeMember [ ^ ],
动态加载用户控件 [ ^ ]。
I’m writing a program which is based on plugin, generally we have a database which has customer list like name and etc plugin written for this project is supposed to calculate the incoming data (information) , assume that there are 4 individuals which are going to write 4 plugins for this program , for instance one obtains the number of customers and the second plugin calculates the debts and etc The thing is how can I enter the customer list in the interface input in a way that ones who write plugins won’t get involved in database and have the information from the interface input and do their job subsequently
namespace PluginBasdeApp.PluginDefenition{
public interface IPlugin
{
string Name { get; }
List<IAction> Actions { get; }
}
}
namespace PluginBasdeApp.PluginDefenition{
public interface IAction
{
string Name { get; }
List<Customer> Run(List<Customer> customers );
}
}
One approach to plugins is using Microsoft MEF:
http://en.wikipedia.org/wiki/Managed_Extensibility_Framework[^],
http://mef.codeplex.com[^],
http://msdn.microsoft.com/en-us/library/dd460648%28VS.100%29.aspx[^].
Alternatively, you can create much simpler plug-in architecture using reflection. I explained the main ideas in my past answers:
Access a custom object that resides in plug in dll[^],
Gathering types from assemblies by it's string representation[^],
Projects and DLL's: How to keep them managable?[^],
C# Reflection InvokeMember on existing instance[^],
Dynamically Load User Controls[^].