使用 Mono.Addins 本地条件

发布于 2024-09-14 07:32:59 字数 217 浏览 1 评论 0原文

此处所述,您如何“在 AddinManager 上注册 ConditionType 的实例”?

As described here how do you " register an instance of the ConditionType" on the AddinManager?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然#的苍凉 2024-09-21 07:32:59

您发现文档中存在空白。现在已更新。

要在本地条件下使用扩展点,您必须创建扩展上下文,设置条件,然后查询扩展点。例如:

// Create an extension context to be used to query the extension point using
// a specific set of conditions.
ExtensionContext ctx = AddinManager.CreateExtensionContext ();

// Create and register the extension point condition
OpenFileLocalCondition condition = new OpenFileLocalCondition (someFileName);
ctx.RegisterCondition (condition);

// Query the extension point
foreach (ExtensionNode node in ctx.GetExtensionNodes ("/TextEditor/ContextMenu"))
    (...)

您在上下文中注册的条件仅适用于该上下文,因此您可以拥有多个具有不同条件集的上下文。

You found a gap in the documentation. It is now updated.

To use extension points with local conditions, you have to create an Extension Context, setup the conditions, and then query the extension point. For example:

// Create an extension context to be used to query the extension point using
// a specific set of conditions.
ExtensionContext ctx = AddinManager.CreateExtensionContext ();

// Create and register the extension point condition
OpenFileLocalCondition condition = new OpenFileLocalCondition (someFileName);
ctx.RegisterCondition (condition);

// Query the extension point
foreach (ExtensionNode node in ctx.GetExtensionNodes ("/TextEditor/ContextMenu"))
    (...)

The conditions you register on a context only apply to that context, so you can have several contexts with different sets of conditions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文