Пример #1
0
        private void LoadMirrorInfo()
        {
            string   mirrorUrl  = string.Format("http://www.thetvdb.com/api/{0}/mirrors.xml", apiKey);
            XElement mirrors    = IOUtil.LoadXml(mirrorUrl).Element("Mirrors");
            var      xmlMirrors =
                from m in mirrors.Elements("Mirror")
                where (Convert.ToInt32(m.Element("typemask").Value) & 1) != 0
                select m.Element("mirrorpath");

            var bannerMirrors =
                from m in mirrors.Elements("Mirror")
                where (Convert.ToInt32(m.Element("typemask").Value) & 2) != 0
                select m.Element("mirrorpath");

            var zipMirrors =
                from m in mirrors.Elements("Mirror")
                where (Convert.ToInt32(m.Element("typemask").Value) & 4) != 0
                select m.Element("mirrorpath");

            Random rand = new Random(DateTime.Now.Millisecond);

            MirrorInfo = new MirrorInfo
            {
                XmlMirror    = xmlMirrors.ElementAt(rand.Next(0, xmlMirrors.Count())).Value,
                BannerMirror = bannerMirrors.ElementAt(rand.Next(0, xmlMirrors.Count())).Value,
                ZipMirror    = zipMirrors.ElementAt(rand.Next(0, xmlMirrors.Count())).Value
            };
            LastUpdate = Convert.ToInt32(IOUtil.LoadXml("http://www.thetvdb.com/api/Updates.php?type=none").Element("Items").Element("Time").Value);
        }
Пример #2
0
 private void LoadMirrorInfo()
 {
     string mirrorUrl = string.Format("http://www.thetvdb.com/api/{0}/mirrors.xml", apiKey);
     XElement mirrors = IOUtil.LoadXml(mirrorUrl).Element("Mirrors");
     var xmlMirrors =
         from m in mirrors.Elements("Mirror")
         where (Convert.ToInt32(m.Element("typemask").Value) & 1) != 0
         select m.Element("mirrorpath");
     var bannerMirrors =
         from m in mirrors.Elements("Mirror")
         where (Convert.ToInt32(m.Element("typemask").Value) & 2) != 0
         select m.Element("mirrorpath");
     var zipMirrors =
         from m in mirrors.Elements("Mirror")
         where (Convert.ToInt32(m.Element("typemask").Value) & 4) != 0
         select m.Element("mirrorpath");
     Random rand = new Random(DateTime.Now.Millisecond);
     MirrorInfo = new MirrorInfo
                      {
                          XmlMirror = xmlMirrors.ElementAt(rand.Next(0, xmlMirrors.Count())).Value,
                          BannerMirror = bannerMirrors.ElementAt(rand.Next(0, xmlMirrors.Count())).Value,
                          ZipMirror = zipMirrors.ElementAt(rand.Next(0, xmlMirrors.Count())).Value
                      };
     LastUpdate = Convert.ToInt32(IOUtil.LoadXml("http://www.thetvdb.com/api/Updates.php?type=none").Element("Items").Element("Time").Value);
 }