Exemplo n.º 1
0
        /// <summary>
        /// This is overridden to allow proper comparison of <c>SpellCheckerDictionary</c> objects
        /// </summary>
        /// <param name="obj">The object to which this instance is compared</param>
        /// <returns>Returns true if the object equals this instance, false if it does not</returns>
        public override bool Equals(object obj)
        {
            SpellingSuggestion s = obj as SpellingSuggestion;

            return(s != null && ((this.Culture == null && s.Culture == null) ||
                                 (this.Culture != null && s.Culture != null && this.Culture.Name == s.Culture.Name)) &&
                   this.Suggestion == s.Suggestion);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is used to replace all occurrences of the specified word
        /// </summary>
        /// <param name="word">The word to be replaced</param>
        /// <param name="replacement">The suggestion to use as the replacement</param>
        public void ReplaceAllOccurrences(string word, SpellingSuggestion replacement)
        {
            var handler = ReplaceAll;

            if (handler != null)
            {
                handler(this, new SpellingEventArgs(word, replacement));
            }
        }
Exemplo n.º 3
0
        //=====================================================================
        /// <summary>
        /// Returns a value indicating whether two specified instances of <c>SpellingSuggestion</c> are equal
        /// </summary>
        /// <param name="s1">The first suggestion to compare</param>
        /// <param name="s2">The second suggestion to compare</param>
        /// <returns>Returns true if the suggestions are equal, false if they are not</returns>
        public static bool Equals(SpellingSuggestion s1, SpellingSuggestion s2)
        {
            if((object)s1 == null && (object)s2 == null)
                return true;

            if((object)s1 == null)
                return false;

            return s1.Equals(s2);
        }
Exemplo n.º 4
0
        //=====================================================================

        /// <summary>
        /// Returns a value indicating whether two specified instances of <c>SpellingSuggestion</c> are equal
        /// </summary>
        /// <param name="s1">The first suggestion to compare</param>
        /// <param name="s2">The second suggestion to compare</param>
        /// <returns>Returns true if the suggestions are equal, false if they are not</returns>
        public static bool Equals(SpellingSuggestion s1, SpellingSuggestion s2)
        {
            if (s1 == null && s2 == null)
            {
                return(true);
            }

            if (s1 == null)
            {
                return(false);
            }

            return(s1.Equals(s2));
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="word">The word related to the event</param>
        /// <param name="replacement">The replacement to use.  If null, an empty string is used.</param>
        public SpellingEventArgs(string word, SpellingSuggestion replacement)
        {
            if(String.IsNullOrWhiteSpace(word))
                throw new ArgumentException("The word cannot be null or empty", "word");

            this.Word = word;

            if(replacement == null)
                this.ReplacementWord = String.Empty;
            else
            {
                this.Culture = replacement.Culture;
                this.ReplacementWord = String.IsNullOrWhiteSpace(replacement.Suggestion) ? String.Empty :
                    replacement.Suggestion;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="word">The word related to the event</param>
        /// <param name="replacement">The replacement to use.  If null, an empty string is used.</param>
        public SpellingEventArgs(string word, SpellingSuggestion replacement)
        {
            if (String.IsNullOrWhiteSpace(word))
            {
                throw new ArgumentException("The word cannot be null or empty", "word");
            }

            this.Word = word;

            if (replacement == null)
            {
                this.ReplacementWord = String.Empty;
            }
            else
            {
                this.Culture         = replacement.Culture;
                this.ReplacementWord = String.IsNullOrWhiteSpace(replacement.Suggestion) ? String.Empty :
                                       replacement.Suggestion;
            }
        }
        /// <summary>
        /// This is used to replace all occurrences of the specified word
        /// </summary>
        /// <param name="word">The word to be replaced</param>
        /// <param name="replacement">The suggestion to use as the replacement</param>
        public void ReplaceAllOccurrences(string word, SpellingSuggestion replacement)
        {
            var handler = ReplaceAll;

            if(handler != null)
                handler(this, new SpellingEventArgs(word, replacement));
        }