private void ReloadMountedDrives() { var oldRoots = _mountedDrives.Select(d => d.RootDirectory).ToHashSet(); var drives = GetMountedDrives(); var newRoots = drives.Select(d => d.RootDirectory).ToHashSet(); var addedDrives = drives.Where(dm => !oldRoots.Contains(dm.RootDirectory)); var removedDrives = MountedDrives.Where(dm => !newRoots.Contains(dm.RootDirectory)); if (addedDrives.Any() || removedDrives.Any()) { _mountedDrives.Clear(); _mountedDrives.AddRange(drives); DrivesListChanged.Raise(this, EventArgs.Empty); } }
private async Task ReloadUnmountedDrivesAsync() { var unmountedDrives = await _unmountedDriveService.GetUnmountedDrivesAsync(); var oldRoots = _unmountedDrives.Select(d => d.FullName).ToHashSet(); var newRoots = unmountedDrives.Select(d => d.FullName).ToHashSet(); var addedDrives = unmountedDrives.Where(udm => !oldRoots.Contains(udm.FullName)); var removedDrives = UnmountedDrives.Where(udm => !newRoots.Contains(udm.FullName)); if (addedDrives.Any() || removedDrives.Any()) { _unmountedDrives.Clear(); _unmountedDrives.AddRange(unmountedDrives); DrivesListChanged.Raise(this, EventArgs.Empty); } }