110,536
社区成员
发帖
与我相关
我的任务
分享
private void ToolStripMenuItem_Plugin_Click(object sender, EventArgs e)
{
ToolStripMenuItem mi = (ToolStripMenuItem)sender;
string asmFile=null;
System.Reflection.Assembly assembly = null;
//MessageBox.Show(mi.Text);
try
{
foreach (KeyValuePair<string, string> val in this.pluginName)
{
if (val.Key == mi.Text)
{
asmFile = val.Value;
break;
}
}
if (asmFile != string.Empty)
{
assembly = System.Reflection.Assembly.LoadFrom(asmFile);
foreach (Type type in assembly.GetTypes())
{
if (!type.IsClass || type.IsNotPublic) continue;
Type[] tempInterfaces = type.GetInterfaces();
if (((IList)tempInterfaces).Contains(typeof(PluginInterface.Plugin)))
{
PluginInterface.Plugin plugin = (PluginInterface.Plugin)System.Activator.CreateInstance(type);
MessageBox.Show(plugin.GetPluginName());
}
}
}
}
catch
{
Messages.Instance().Msgbox("异常!");
}
}