Esempio n. 1
0
 public void ParseToList(XElement el, Whitelist whitelist)
 {
     foreach (var node in el.Elements())
     {
         if (node.Elements().Any())
         {
             ParseToList(node, whitelist);
         }
         else
         {
             var value = node.Attributes().FirstOrDefault(x => x.Name == "value")?.Value;
             whitelist.Builds.Add(new WhiteListApp {
                 Value = value
             });
         }
     }
 }
Esempio n. 2
0
        public void Load()
        {
            var file = new FileInfo(_path);

            if (file.Directory != null && !file.Exists)
            {
                Directory.CreateDirectory(file.Directory.FullName);
                var xml = new XDocument(new XElement("whiteList", new XElement("builds")));
                xml.Save(_path);
            }

            var whitelistFile = XElement.Load(_path);
            var whitelist     = new Whitelist();

            ParseToList(whitelistFile, whitelist);

            _whitelist = whitelist;
        }
Esempio n. 3
0
        public void Load()
        {
            Whitelist whitelist;
            var       file = new FileInfo(_path);

            if (file.Directory != null && !file.Exists)
            {
                Directory.CreateDirectory(file.Directory.FullName);
                var xml = new XDocument(new XElement("whiteList", new XElement("builds")));
                xml.Save(_path);
            }

            using (var streamReader = new StreamReader(_path))
            {
                var serializer = new XmlSerializer(typeof(Whitelist));

                whitelist = (Whitelist)serializer.Deserialize(streamReader);
            }

            _whitelist = whitelist;
        }