Imports and exports a registry key tree from or to XML.
Esempio n. 1
0
        /// <summary>
        /// Imports a registry XML file.
        /// </summary>
        /// <param name="path">Path to the registry XML file to import.</param>
        /// <param name="properties">Optional properties to replace during import.</param>
        internal void Import(string path, Dictionary <string, string> properties = null)
        {
            var settings = new XmlReaderSettings();

            settings.CloseInput     = true;
            settings.IgnoreComments = true;
            settings.IgnoreProcessingInstructions = true;
            settings.IgnoreWhitespace             = true;
            settings.DtdProcessing = DtdProcessing.Prohibit;

            var absolutePath = System.IO.Path.Combine(Environment.CurrentDirectory, path);

            using (var reader = XmlReader.Create(absolutePath, settings))
            {
                var importer = new RegistryXml();
                if (null != properties)
                {
                    // Overwrite or add whatever is there by default.
                    foreach (var pair in properties)
                    {
                        importer.Properties[pair.Key] = pair.Value;
                    }
                }

                importer.Import(reader);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Imports a registry XML file.
        /// </summary>
        /// <param name="path">Path to the registry XML file to import.</param>
        /// <param name="properties">Optional properties to replace during import.</param>
        internal void Import(string path, Dictionary<string, string> properties = null)
        {
            var settings = new XmlReaderSettings();
            settings.CloseInput = true;
            settings.IgnoreComments = true;
            settings.IgnoreProcessingInstructions = true;
            settings.IgnoreWhitespace = true;
            settings.DtdProcessing = DtdProcessing.Prohibit;

            var absolutePath = System.IO.Path.Combine(Environment.CurrentDirectory, path);
            using (var reader = XmlReader.Create(absolutePath, settings))
            {
                var importer = new RegistryXml();
                if (null != properties)
                {
                    // Overwrite or add whatever is there by default.
                    foreach (var pair in properties)
                    {
                        importer.Properties[pair.Key] = pair.Value;
                    }
                }

                importer.Import(reader);
            }
        }