当前位置: 动力学知识库 > 问答 > 编程问答 >

vsx - VSIX: subscribe to command

问题描述:

How do I subscribe to a 3rdparty extension's command from my own VSIX extension? Such as OnClick event of an extension.

网友答案:

If it is a command, you should be able to capture it using DTE.Events.CommandEvents[commandGuid, commandId].BeforeExecute (or AfterExecute). (MSDN)

If you do not know the ID and GUID you can subscribe to all commands (as both indexer parameters are optional), add logging of ID/GUID, then use the command you are interested in.

Important Note:
I believe you have to keep a reference to DTE.Events.CommandEvents[commandGuid, commandId] somewhere so it will not be garbage collected. Otherwise you may lose your subscription.

分享给朋友:
您可能感兴趣的文章:
随机阅读: