public virtual Pageable <CustomLocation> GetAll(CancellationToken cancellationToken = default) { Page <CustomLocation> FirstPageFunc(int?pageSizeHint) { using var scope = _customLocationClientDiagnostics.CreateScope("CustomLocationCollection.GetAll"); scope.Start(); try { var response = _customLocationRestClient.ListByResourceGroup(Id.SubscriptionId, Id.ResourceGroupName, cancellationToken: cancellationToken); return(Page.FromValues(response.Value.Value.Select(value => new CustomLocation(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } Page <CustomLocation> NextPageFunc(string nextLink, int?pageSizeHint) { using var scope = _customLocationClientDiagnostics.CreateScope("CustomLocationCollection.GetAll"); scope.Start(); try { var response = _customLocationRestClient.ListByResourceGroupNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, cancellationToken: cancellationToken); return(Page.FromValues(response.Value.Value.Select(value => new CustomLocation(Client, value)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc)); }