public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
            {
                var commandKey = new GherkinEditorCommandTargetKey(pguidCmdGroup, prgCmds[0].cmdID);

                IGherkinEditorCommand[] commands;
                if (CommandRegistry.TryGetValue(commandKey, out commands))
                {
                    foreach (var editorCommand in commands)
                    {
                        var status = editorCommand.QueryStatus(TextView, pguidCmdGroup, prgCmds[0].cmdID);
                        if (status != GherkinEditorCommandStatus.NotSupported)
                        {
                            prgCmds[0].cmdf = (uint)OLECMDF.OLECMDF_SUPPORTED;
                            if (status == GherkinEditorCommandStatus.Supported)
                            {
                                prgCmds[0].cmdf |= (uint)OLECMDF.OLECMDF_ENABLED;
                            }
                            return(VSConstants.S_OK);
                        }
                    }
                }

                return(Next.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText));
            }
            public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
            {
                bool handled = false;
                int  hresult = VSConstants.S_OK;

                var commandKey = new GherkinEditorCommandTargetKey(pguidCmdGroup, nCmdID);

                IGherkinEditorCommand[] commands;
                if (!CommandRegistry.TryGetValue(commandKey, out commands))
                {
                    return(Next.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
                }

                // Pre-process
                foreach (var editorCommand in commands)
                {
                    handled = editorCommand.PreExec(TextView, pguidCmdGroup, nCmdID, pvaIn);
                    if (handled)
                    {
                        break;
                    }
                }

                if (!handled)
                {
                    hresult = Next.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
                }

                // Post-process
                foreach (var editorCommand in commands)
                {
                    editorCommand.PostExec(TextView, pguidCmdGroup, nCmdID, pvaIn);
                }

                return(hresult);
            }
 public bool Equals(GherkinEditorCommandTargetKey other)
 {
     return(CommandGroup.Equals(other.CommandGroup) && CommandId == other.CommandId);
 }