闲谈可插拔式应用程序的开发
2010-10-09 08:16:14 来源:WEB开发网运行结果如下:
查看原图(大图)
开发两个插件,都继承IPlugin。
手机短信通知插件:
public class PluginA : IPlugin
{
public void Initialize(IPluginHost pluginHost)
{
IPluginHost myApplication = (IPluginHost)pluginHost;
myApplication.AddMenuItem("Click me", OnClick);
}
private void OnClick(string name)
{
Console.WriteLine("Omg! You clicked me!");
}
public void DoSomething()
{
Console.WriteLine("手机短信通知:中秋快乐");
}
}
MSN通知插件:
public class PluginB : IPlugin
{
public void Initialize(IPluginHost pluginHost)
{
IPluginHost myApplication = (IPluginHost)pluginHost;
myApplication.AddMenuItem("Click me", OnClick);
}
private void OnClick(string name)
{
Console.WriteLine("Omg! You clicked me!");
}
public void DoSomething()
{
Console.WriteLine("MSN信息通知:中秋快乐");
}
}
更多精彩
赞助商链接