Beispiel #1
0
        public override TOutput BuildObject <TOutput, TInput>(TInput raw)
        {
            //try {
            var objs   = raw as List <object>;
            var device = objs.FirstOrDefault() as DiscoveredSsdpDevice;

            objs.RemoveAt(0);
            var info = objs.FirstOrDefault() as SsdpDevice;

            var Uuid = (info.CustomProperties?.Count > 0 ?
                        info.CustomProperties.FirstOrDefault(x => x.Name.Equals("X_hardwareId") || x.Name.Equals("deviceID"))?.Value : info.Uuid) ?? "";

            var foundDevice = new FoundDevice
            {
                IpAddress  = device.DescriptionLocation.DnsSafeHost,
                DeviceName = info.FriendlyName,
                DeviceId   = Uuid.Replace("-", "") ?? Utils.Common,
                FoundUsing = "SSdp",
                FoundAt    = device.AsAt.LocalDateTime
            };

            return((TOutput)Convert.ChangeType(foundDevice, foundDevice.GetType()));

            //}catch(NullReferenceException ex){Console.WriteLine(ex.Message);throw ex;}
        }
Beispiel #2
0
        public virtual T BuildObject <T>(string ip)
        {
            var fd = new FoundDevice
            {
                IpAddress  = ip,
                DeviceId   = Utils.Common,
                DeviceName = Utils.Common,
                FoundAt    = DateTime.Now,
                FoundUsing = Utils.Common
            };

            return((T)Convert.ChangeType(fd, fd.GetType()));
        }
Beispiel #3
0
        public override TOutput BuildObject <TOutput, TInput>(TInput raw)
        {
            var itm    = raw as List <object>;
            var device = itm.FirstOrDefault() as DiscoveredSsdpDevice;
            var info   = itm.LastOrDefault() as SsdpDevice;

            var foundDevice = new FoundDevice
            {
                DeviceId   = info.Uuid.Replace("-", ""),
                DeviceName = info.FriendlyName,
                FoundAt    = device.AsAt.LocalDateTime,
                IpAddress  = device.DescriptionLocation.DnsSafeHost,
                FoundUsing = "UPNP"
            };

            return((TOutput)Convert.ChangeType(foundDevice, foundDevice.GetType()));
        }