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