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 DeveroomEditorCommandTargetKey(pguidCmdGroup, nCmdID);

                if (!CommandRegistry.TryGetValue(commandKey, out var commands))
                {
                    return(Next.Exec(commandKey.CommandGroup, commandKey.CommandId, nCmdexecopt, pvaIn, pvaOut));
                }

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

                if (!handled)
                {
                    hresult = Next.Exec(commandKey.CommandGroup, commandKey.CommandId, nCmdexecopt, pvaIn, pvaOut);
                }

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

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

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

                return(Next.QueryStatus(pguidCmdGroup, cCmds, prgCmds, pCmdText));
            }
        public override bool PostExec(IWpfTextView textView, DeveroomEditorCommandTargetKey commandKey, IntPtr inArgs = default(IntPtr))
        {
            char ch = GetTypeChar(inArgs);

            return(PostExec(textView, ch));
        }
 public virtual bool PreExec(IWpfTextView textView, DeveroomEditorCommandTargetKey commandKey, IntPtr inArgs = default(IntPtr))
 {
     return(false);
 }
 public virtual DeveroomEditorCommandStatus QueryStatus(IWpfTextView textView, DeveroomEditorCommandTargetKey commandKey)
 {
     return(DeveroomEditorCommandStatus.Supported);
 }
 public bool Equals(DeveroomEditorCommandTargetKey other)
 {
     return(CommandGroup.Equals(other.CommandGroup) && CommandId == other.CommandId);
 }