Ejemplo n.º 1
0
            public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
            {
                switch (_layer)
                {
                case CommandFilterLayer.PreLanguage:
                    return(_window.PreLanguageCommandFilterQueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));

                case CommandFilterLayer.PreEditor:
                    return(_window.PreEditorCommandFilterQueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
                }

                throw new InvalidOperationException();
            }
            public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                try
                {
                    return(_layer switch
                    {
                        CommandFilterLayer.PreLanguage => _window.PreLanguageCommandFilterQueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText),
                        CommandFilterLayer.PreEditor => _window.PreEditorCommandFilterQueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText),
                        _ => throw ExceptionUtilities.UnexpectedValue(_layer),
                    });
                }
            public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
            {
                try
                {
                    switch (_layer)
                    {
                    case CommandFilterLayer.PreLanguage:
                        return(_window.PreLanguageCommandFilterQueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));

                    case CommandFilterLayer.PreEditor:
                        return(_window.PreEditorCommandFilterQueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));

                    default:
                        throw ExceptionUtilities.UnexpectedValue(_layer);
                    }
                }
                catch (Exception e) when(FatalError.ReportWithoutCrashUnlessCanceled(e))
                {
                    // Exceptions should not escape from command filters.
                    return(_window._editorCommandFilter.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
                }
            }