开发者

Using Mono.Addins local conditions

As described here how do you " register an instance of the Conditio开发者_开发技巧nType" on the AddinManager?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜