private async Task AllocateSpace(ByteSize requiredSize) { Log.Information("Verifying available space"); Log.Verbose("Verifying the available space..."); Log.Verbose("We will need {Size} of free space for Windows", requiredSize); var hasEnoughSpace = await phone.HasEnoughSpace(requiredSize); if (!hasEnoughSpace) { Log.Verbose("There's not enough space in the phone. We will try to allocate it automatically"); var success = await spaceAllocators.ToObservable() .Select(x => Observable.FromAsync(() => x.TryAllocate(phone, requiredSize))) .Merge(1) .Any(successful => successful); if (!success) { Log.Verbose("Allocation attempt failed"); throw new NotEnoughSpaceException($"Could not allocate {requiredSize} on the phone. Please, try to allocate the necessary space manually and retry."); } Log.Verbose("Space allocated correctly"); } else { Log.Verbose("We have enough available space to deploy Windows"); } }