摘要:
定义插件接口// PluginInterface.cs// 插件的公用接口// 编译命令:csc /target:library PluginInterface.csusing System;public interface IPlugin{ // 插件名称 string Name { get; } // 实现插件功能的方法 object DoWork(object parameter);} 定义插件宿主接口// HostInterface.cs// 插件宿主的公用接口// 编译命令:csc /target:library HostInter... 阅读全文
摘要:
之前对反射的 学习和使用过程中 ,发现 有时会使用 CreateInstance创建实例 然后调用方法 、参数等而有时 是通过type的一些方法 访问类中的方法和参数。。。这两者有什么区别呢?这是type的方式:Assembly ass = Assembly.Load(程序集);Type itype = ass.GetType(类名);MethodInfo method1 = itype.GetMethod(方法名);string s1 = (string)method1.Invoke(null, param1); CreateInstance创建实例的简单:MethodInfo metho. 阅读全文