コード例 #1
0
ファイル: UpnpDeviceMerger.cs プロジェクト: kthompson/Upnp
        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);
        }
コード例 #2
0
ファイル: UpnpDeviceMerger.cs プロジェクト: sjndhkl/Upnp
        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);
            }
        }
コード例 #3
0
ファイル: UpnpDeviceMerger.cs プロジェクト: sjndhkl/Upnp
        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);
            }
        }
コード例 #4
0
ファイル: UpnpDeviceMerger.cs プロジェクト: kthompson/Upnp
        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);
            }
        }
コード例 #5
0
 public static IEnumerable <UpnpService> EnumerateServices(this UpnpDevice @this)
 {
     return(@this.EnumerateDevices().SelectMany(device => device.Services));
 }
コード例 #6
0
 public static IEnumerable <UpnpDevice> FindByUdn(this UpnpDevice device, string udn)
 {
     return(device.EnumerateDevices().Where(d => d.UDN == udn));
 }
コード例 #7
0
 public static IEnumerable <UpnpDevice> FindByDeviceType(this UpnpDevice @this, UpnpType type)
 {
     return(@this.EnumerateDevices().Where(d => d.Type.Equals(type)));
 }