Exemple #1
0
        public void Compare(UpnpDevice to, UpnpDevice from)
        {
            if(from == null)
                return;

            var fromChildren = from.EnumerateDevices().ToList();
            var toChildren = to.EnumerateDevices().ToList();

            foreach (var toChild in toChildren)
            {
                var fromChild = FindMatchFor(toChild, fromChildren);
                if (fromChild == null)
                {
                    //fromChild doesnt exist so was removed
                    DeviceRemoved(toChild);
                    continue;
                }

                // remove the child so we can see if there are any new ones at the end.
                fromChildren.Remove(fromChild);
                CompareDevices(toChild, fromChild);
            }

            //these devices were not found in the 'to' device so they are new
            if (fromChildren.Count > 0)
                ProcessAddedDevices(to, fromChildren);
        }
Exemple #2
0
        public void Compare(UpnpDevice to, UpnpDevice from)
        {
            if (from == null)
            {
                return;
            }

            var fromChildren = from.EnumerateDevices().ToList();
            var toChildren   = to.EnumerateDevices().ToList();

            foreach (var toChild in toChildren)
            {
                var fromChild = FindMatchFor(toChild, fromChildren);
                if (fromChild == null)
                {
                    //fromChild doesnt exist so was removed
                    DeviceRemoved(toChild);
                    continue;
                }

                // remove the child so we can see if there are any new ones at the end.
                fromChildren.Remove(fromChild);
                CompareDevices(toChild, fromChild);
            }

            //these devices were not found in the 'to' device so they are new
            if (fromChildren.Count > 0)
            {
                ProcessAddedDevices(to, fromChildren);
            }
        }
Exemple #3
0
        private void ProcessAddedDevices(UpnpDevice to, List <UpnpDevice> addedDevices)
        {
            var toChildren = to.EnumerateDevices().ToList();

            foreach (var device in addedDevices)
            {
                //cant update root device
                if (device.Parent == null)
                {
                    continue;
                }

                //find the original 'to' parent
                var toChild = FindMatchFor(device.Parent, toChildren);
                if (toChild == null)
                {
                    continue;
                }


                DeviceAdded(toChild, device);
            }
        }
Exemple #4
0
        private void ProcessAddedDevices(UpnpDevice to, List<UpnpDevice> addedDevices)
        {
            var toChildren = to.EnumerateDevices().ToList();

            foreach (var device in addedDevices)
            {
                //cant update root device
                if(device.Parent == null)
                    continue;

                //find the original 'to' parent
                var toChild = FindMatchFor(device.Parent, toChildren);
                if(toChild == null)
                    continue;

                DeviceAdded(toChild, device);
            }
        }
Exemple #5
0
 public static IEnumerable <UpnpService> EnumerateServices(this UpnpDevice @this)
 {
     return(@this.EnumerateDevices().SelectMany(device => device.Services));
 }
Exemple #6
0
 public static IEnumerable <UpnpDevice> FindByUdn(this UpnpDevice device, string udn)
 {
     return(device.EnumerateDevices().Where(d => d.UDN == udn));
 }
Exemple #7
0
 public static IEnumerable <UpnpDevice> FindByDeviceType(this UpnpDevice @this, UpnpType type)
 {
     return(@this.EnumerateDevices().Where(d => d.Type.Equals(type)));
 }