public async Task Update(IEnumerable <PathInfo> paths = null) { await Task.Run(() => { // General info Id = Device.Id; Name = Device.Name; Description = Device.Description; // Sub devices devices.Clear(); DeviceHub deviceHub = Device as DeviceHub; if (deviceHub != null) { foreach (Device device in deviceHub.Devices) { devices.Add(DeviceInfo.Get(device)); } } // Services /*services.Clear(); * * foreach (Service service in Device.Services) * services.Add(ServiceInfo.Get(service));*/ Updated?.Invoke(this, EventArgs.Empty); }); }
public virtual Device FindDevice(params Guid[] path) { if (path == null || path.Length == 0) { throw new IndexOutOfRangeException("The specified path is not valid"); } Device device = Devices.FirstOrDefault(d => d.Id == path[0]); if (device == null) { throw new Exception("Could not find any device matching the secified path"); } if (path.Length == 1) { return(device); } DeviceHub deviceHub = device as DeviceHub; if (deviceHub == null) { throw new Exception("One element in the path is not a device hub"); } return(deviceHub.FindDevice(path.Skip(1).ToArray())); }