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); }
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); } }
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); } }
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); } }
public static IEnumerable <UpnpService> EnumerateServices(this UpnpDevice @this) { return(@this.EnumerateDevices().SelectMany(device => device.Services)); }
public static IEnumerable <UpnpDevice> FindByUdn(this UpnpDevice device, string udn) { return(device.EnumerateDevices().Where(d => d.UDN == udn)); }
public static IEnumerable <UpnpDevice> FindByDeviceType(this UpnpDevice @this, UpnpType type) { return(@this.EnumerateDevices().Where(d => d.Type.Equals(type))); }