public void AddSubstitution(
            SettingsManager settingsManager,
            string search,
            string replacement,
            SubstitutionOptions options)
        {
            // Create the substitution we'll be registering.
            var substitution = new RegisteredSubstitution(search, replacement, options);

            // Grab the configuration object for this settings manager or create one if
            // it doesn't already exist.
            var settings =
                settingsManager.Get <ImmediateCorrectionSettings>(
                    ImmediateCorrectionSettings.SettingsPath);

            settings.Substitutions.Add(substitution);

            // Mark that our substituions are out of date.
            optimizedSubstitions = false;
        }
コード例 #2
0
        public void ReadXml(XmlReader reader)
        {
            // We are already at the starting point of this element, so read until the
            // end.
            string elementName = reader.LocalName;

            // Read until we get to the end element.
            while (reader.Read())
            {
                // If we aren't in our namespace, we don't need to bother.
                if (reader.NamespaceURI != XmlConstants.ProjectNamespace)
                {
                    continue;
                }

                // If we got to the end of the node, then stop reading.
                if (reader.LocalName == elementName)
                {
                    return;
                }

                // Look for a key, if we have it, set that value.
                if (reader.NodeType == XmlNodeType.Element &&
                    reader.LocalName == "substitution")
                {
                    // Pull out the settings.
                    string search      = reader["search"];
                    string replacement = reader["replace"];
                    var    options     =
                        (SubstitutionOptions)
                        Enum.Parse(typeof(SubstitutionOptions), reader["options"]);

                    // Add in the substitution.
                    var substitution = new RegisteredSubstitution(search, replacement, options);
                    Substitutions.Add(substitution);
                }
            }
        }