Example #1
0
        private static RegistryRoot ReadRegistry(XmlReader reader)
        {
            List <RegistryKey> keys = new List <RegistryKey>();

            reader.MoveToElement();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement &&
                    string.Equals(RegistryElementName, reader.Name))
                {
                    break;
                }
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                switch (reader.Name)
                {
                case KeyElementName:
                    RegistryKey registryKey = ReadRegistryKey(reader);
                    keys.Add(registryKey);
                    break;
                }
            }
            RegistryRoot registry = new RegistryRoot(keys);

            return(registry);
        }
Example #2
0
 public static RegistryRoot Parse(string xml)
 {
     using (StringReader stringReader = new StringReader(xml))
     {
         using (XmlReader reader = XmlReader.Create(stringReader))
         {
             RegistryRoot registry = ReadRegistry(reader);
             return(registry);
         }
     }
 }