Exemplo n.º 1
0
        public virtual Pageable <WebSite> GetWebApps(string skipToken = null, string filter = null, string top = null, CancellationToken cancellationToken = default)
        {
            Page <WebSite> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _appServicePlanClientDiagnostics.CreateScope("AppServicePlan.GetWebApps");
                scope.Start();
                try
                {
                    var response = _appServicePlanRestClient.ListWebApps(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, skipToken, filter, top, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new WebSite(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <WebSite> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _appServicePlanClientDiagnostics.CreateScope("AppServicePlan.GetWebApps");
                scope.Start();
                try
                {
                    var response = _appServicePlanRestClient.ListWebAppsNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, skipToken, filter, top, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new WebSite(Client, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc));
        }