Exemple #1
0
        /// <summary>
        /// This method is executed when action is selected in the context menu.
        /// </summary>
        public void Invoke()
        {
            bool succeeded;

            switch (action)
            {
            case DictionaryAction.IgnoreOnce:
                dictionary.IgnoreWordOnce(span);
                succeeded = true;
                break;

            case DictionaryAction.IgnoreAll:
                succeeded = dictionary.IgnoreWord(span.GetText(span.TextBuffer.CurrentSnapshot));
                break;

            default:
                succeeded = dictionary.AddWordToDictionary(span.GetText(span.TextBuffer.CurrentSnapshot));
                break;
            }

            Debug.Assert(succeeded, "Call to modify dictionary was unsuccessful");
        }
        //=====================================================================

        /// <inheritdoc />
        public override void Invoke(CancellationToken cancellationToken)
        {
            bool succeeded;

            switch (action)
            {
            case DictionaryAction.IgnoreOnce:
                dictionary.IgnoreWordOnce(this.Span);
                succeeded = true;
                break;

            case DictionaryAction.IgnoreAll:
                succeeded = dictionary.IgnoreWord(this.Span.GetText(this.Span.TextBuffer.CurrentSnapshot));
                break;

            default:
                succeeded = dictionary.AddWordToDictionary(this.Span.GetText(
                                                               this.Span.TextBuffer.CurrentSnapshot), culture);
                break;
            }

            Debug.Assert(succeeded, "Call to modify dictionary was unsuccessful");
        }