TypoError() статический приватный Метод

static private TypoError ( string error ) : void
error string
Результат void
Пример #1
0
        public Dictionary <string, string> GetTypos()
        {
            Dictionary <string, string> typoStrings = new Dictionary <string, string>();

            try
            {
                string text = "";
                try
                {
                    text = Tools.GetHTML(Url, Encoding.UTF8);
                }
                catch
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        if (MessageBox.Show("No list of typos was found. Would you like to use the list of typos from the English Wikipedia?\r\nOnly choose 'Yes' if this is an English wiki.", "Load from English Wikipedia?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            try
                            {
                                text = Tools.GetHTML("http://en.wikipedia.org/w/index.php?title=Wikipedia:AutoWikiBrowser/Typos&action=raw", Encoding.UTF8);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("There was a problem loading the list of typos: " + ex.Message);
                            }
                        }
                        else
                        {
                            text = "";
                        }
                    }
                }

                if (string.IsNullOrEmpty(text))
                {
                    return(typoStrings); // Currently an empty dictionary
                }
                foreach (Match m in TypoRegex.Matches(text))
                {
                    try
                    {
                        typoStrings.Add(m.Groups[2].Value, m.Groups[3].Value);
                    }
                    catch (ArgumentException)
                    {
                        RegExTypoFix.TypoError("Duplicate typo rule '" + m.Groups[2].Value + "' found.");
                        return(new Dictionary <string, string>());
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Handle(ex);
                // refuse to accept malformed typo lists to encourage people to correct errors
                return(new Dictionary <string, string>());
            }

            return(typoStrings);
        }
        /// <summary>
        /// Adds one typo regex to the list
        /// </summary>
        public void Add(string typo, string replacement)
        {
            if (!IsSuitableTypo(typo))
            {
                throw new ArgumentException("Typo \"" + typo + "\" is not suitable for this group.");
            }
            Regex r;

            try
            {
                r = new Regex(typo, RegexOptions.Compiled);
            }
            catch (Exception ex)
            {
                RegExTypoFix.TypoError("Error in typo '" + typo + "': " + ex.Message);
                throw new TypoException();
            }

            Typos.Add(new KeyValuePair <Regex, string>(r, replacement));
        }