Example #1
0
        /// <summary>
        /// This is used to save the spell checker configuration settings
        /// </summary>
        /// <remarks>The settings are saved to <b>SpellChecker.config</b> in the <see cref="ConfigurationFilePath"/>
        /// folder.</remarks>
        public static bool SaveConfiguration()
        {
            string filename = Path.Combine(ConfigurationFilePath, "SpellChecker.config");
            bool   success  = true;

            try
            {
                XElement root = new XElement("SpellCheckerConfiguration",
                                             new XElement("DefaultLanguage")
                {
                    Value = DefaultLanguage.Name
                },
                                             IgnoreWordsWithDigits ? new XElement("IgnoreWordsWithDigits") : null,
                                             IgnoreWordsInAllUppercase ? new XElement("IgnoreWordsInAllUppercase") : null,
                                             IgnoreFilenamesAndEMailAddresses ? new XElement("IgnoreFilenamesAndEMailAddresses") : null,
                                             IgnoreXmlElementsInText ? new XElement("IgnoreXmlElementsInText") : null,
                                             TreatUnderscoreAsSeparator ? new XElement("TreatUnderscoreAsSeparator") : null);

                if (ignoredXmlElements.Count != DefaultIgnoredXmlElements.Count() ||
                    DefaultIgnoredXmlElements.Except(ignoredXmlElements).Count() != 0)
                {
                    root.Add(new XElement("IgnoredXmlElements",
                                          ignoredXmlElements.Select(i => new XElement("Ignore")
                    {
                        Value = i
                    })));
                }

                if (spellCheckedXmlAttributes.Count != DefaultSpellCheckedAttributes.Count() ||
                    DefaultSpellCheckedAttributes.Except(spellCheckedXmlAttributes).Count() != 0)
                {
                    root.Add(new XElement("SpellCheckedXmlAttributes",
                                          spellCheckedXmlAttributes.Select(i => new XElement("SpellCheck")
                    {
                        Value = i
                    })));
                }

                root.Save(filename);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                success = false;
            }

            return(success);
        }
Example #2
0
        /// <summary>
        /// This is used to save the spell checker configuration settings
        /// </summary>
        /// <remarks>The settings are saved to <b>SpellChecker.config</b> in the <see cref="ConfigurationFilePath"/>
        /// folder.</remarks>
        public static bool SaveConfiguration()
        {
            string filename = Path.Combine(ConfigurationFilePath, "SpellChecker.config");
            bool   success  = true;

            try
            {
                XElement root = new XElement("SpellCheckerConfiguration",
                                             new XElement("DefaultLanguage")
                {
                    Value = DefaultLanguage.Name
                },
                                             SpellCheckAsYouType ? new XElement("SpellCheckAsYouType") : null,
                                             IgnoreWordsWithDigits ? new XElement("IgnoreWordsWithDigits") : null,
                                             IgnoreWordsInAllUppercase ? new XElement("IgnoreWordsInAllUppercase") : null,
                                             IgnoreFormatSpecifiers ? new XElement("IgnoreFormatSpecifiers") : null,
                                             IgnoreFilenamesAndEMailAddresses ? new XElement("IgnoreFilenamesAndEMailAddresses") : null,
                                             IgnoreXmlElementsInText ? new XElement("IgnoreXmlElementsInText") : null,
                                             TreatUnderscoreAsSeparator ? new XElement("TreatUnderscoreAsSeparator") : null,
                                             new XElement("ExcludeByFilenameExtension", ExcludeByFilenameExtension),
                                             new XElement("IgnoredCharacterClass", IgnoreCharacterClass.ToString()),
                                             IgnoreXmlDocComments ? new XElement("IgnoreXmlDocComments") : null,
                                             IgnoreDelimitedComments ? new XElement("IgnoreDelimitedComments") : null,
                                             IgnoreStandardSingleLineComments ? new XElement("IgnoreStandardSingleLineComments") : null,
                                             IgnoreQuadrupleSlashComments ? new XElement("IgnoreQuadrupleSlashComments") : null,
                                             IgnoreNormalStrings ? new XElement("IgnoreNormalStrings") : null,
                                             IgnoreVerbatimStrings ? new XElement("IgnoreVerbatimStrings") : null);

                if (ignoredWords.Count != DefaultIgnoredWords.Count() ||
                    DefaultIgnoredWords.Except(ignoredWords).Count() != 0)
                {
                    root.Add(new XElement("IgnoredWords",
                                          ignoredWords.Select(i => new XElement("Ignore")
                    {
                        Value = i
                    })));
                }

                if (ignoredXmlElements.Count != DefaultIgnoredXmlElements.Count() ||
                    DefaultIgnoredXmlElements.Except(ignoredXmlElements).Count() != 0)
                {
                    root.Add(new XElement("IgnoredXmlElements",
                                          ignoredXmlElements.Select(i => new XElement("Ignore")
                    {
                        Value = i
                    })));
                }

                if (spellCheckedXmlAttributes.Count != DefaultSpellCheckedAttributes.Count() ||
                    DefaultSpellCheckedAttributes.Except(spellCheckedXmlAttributes).Count() != 0)
                {
                    root.Add(new XElement("SpellCheckedXmlAttributes",
                                          spellCheckedXmlAttributes.Select(i => new XElement("SpellCheck")
                    {
                        Value = i
                    })));
                }

                root.Save(filename);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                success = false;
            }

            return(success);
        }