C#插件事件处理 [英] c# Plugin Event Handling

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

问题描述

我写一个使用界面插件系统和符合本合同在运行到主系统中加载任何插件。

I have written a plugin system that uses an interface and for any plugins that meet this contract are loaded at runtime into the main system.

该插件有效地返回TabPage的被开槽到主应用程序,并控制fromwithin插件的dll

The plugin effectively returns a TabPage that is slotted into the main app, and is controlled fromwithin the plugin dll.

如果插件内发生错误时,标准的Windows错误消息显示。我想这样做创建一个返回的错误信息,所以我可以在我有保留文本的区域显示该事件是什么。

If an error occurs within the plugin, the standard Windows error message shows. What I want to do it create an event that returns the error message so I can display it in the area I have reserved for text.

我需要保持所有连接的插件/接口实例的轨道,以便能够建立一个事件来监视每一个?

Do I need to keep a track of all attached plugin/interface instances to be able to set up an event to monitor each one?

目前,我的系统中循环通过应用程序文件夹内的dll的以及那些符合接口的合同都装起来,界面的实际实例每次丢弃控制,然后交给该dll通过被装入的TabPage和插件内处理按钮事件。

At present, my system loops through the dll's within the app folder and those that meet the interface contract are loaded up, the actual instance of the interface is discarded each time as control is then handed over to the dll via button events that are loaded with the TabPage and handled within the plugin.

我希望这一切是很有意义的。

I hope this all makes sense.

推荐答案

您不需要保持插件类的引用,只需添加一个委托到事件时,启动它,以后就不需要参考了。

You don't need to keep a reference to the plugin class, just add a delegate to the event when you start it up, after that you don't need the reference anymore.

这篇关于C#插件事件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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