Esempio n. 1
0
        public async Task <ZoneTopology> GetTopology(ZoneDevice zoneDevice)
        {
            var target      = zoneDevice.DeviceInfo.BaseAddress + "/status/topology";
            var topologyXml = await new WebClient().DownloadStringAsync(target)
                              .ConfigureAwait(false);

            var topologyElement = XElement.Parse(topologyXml);

            var members = topologyElement
                          .Descendants(XName.Get("ZonePlayer"))
                          .Select(zonePlayerElement => new ZoneMember(zonePlayerElement))
                          .OrderBy(z => z.Title)
                          .ToList();

            return(new ZoneTopology(members));
        }
Esempio n. 2
0
        public async Task <List <ZoneDevice> > FindZoneDevices()
        {
            List <ZoneDevice> zones = null;
            var zoneCount           = 0;

            // try three times to find zones
            for (var i = 0; i < 3; i++)
            {
                zones = await ZoneDevice.FindAndCreateAsync(true);

                zoneCount = zones.Count();
                if (zoneCount > 0)
                {
                    break;
                }
            }
            // TODO: Create error if no zones found!
            if (zones == null || zoneCount <= 0)
            {
                return(zones);
            }
            return(zones);
        }