예제 #1
0
        public virtual Pageable <VirtualMachineRunCommandVirtualMachine> GetAll(string expand = null, CancellationToken cancellationToken = default)
        {
            Page <VirtualMachineRunCommandVirtualMachine> FirstPageFunc(int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("VirtualMachineRunCommandVirtualMachineContainer.GetAll");
                scope.Start();
                try
                {
                    var response = _restClient.GetAllByVirtualMachine(Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new VirtualMachineRunCommandVirtualMachine(Parent, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <VirtualMachineRunCommandVirtualMachine> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using var scope = _clientDiagnostics.CreateScope("VirtualMachineRunCommandVirtualMachineContainer.GetAll");
                scope.Start();
                try
                {
                    var response = _restClient.GetAllByVirtualMachineNextPage(nextLink, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Value.Select(value => new VirtualMachineRunCommandVirtualMachine(Parent, value)), response.Value.NextLink, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

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