Import() 개인적인 메소드

Import a registry key tree from the given XmlReader.
A hive name was specified that is not supported, or a value type was not supported. A general XML exception occured.
private Import ( XmlReader reader ) : void
reader System.Xml.XmlReader The that contains the keys and values to import.
리턴 void
예제 #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);
            }
        }
예제 #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);
            }
        }