public bool MoveNext()

in AdlsDotNetSDK/FileStatusList.cs [199:271]


        public bool MoveNext()
        {
            if (_cancelToken.IsCancellationRequested)
            {
                throw new OperationCanceledException();
            }
            //Not called for first time, first time when this is called ListAfterNext will be whatever client has passed
            if (FileStatus != null)
            {
                _position++;
                //FileStatus.Count will be minimum of ListSize and remaining entries asked by user
                if (_position < FileStatus.Count)//Still more data to be enumerated
                {
                    if (!EnumerateAll)
                    {
                        RemainingEntries--;
                    }
                    return true;
                }
                //Number of entries wanted by the user is already enumerated
                //RemainingEntries 0 means no need to look at server since last time we retrieved "RemainingEntries" number of entries from server
                if (!EnumerateAll && RemainingEntries <= 0)
                {
                    return false;
                }

                // Older behavior for Selection == Minimal. Remove this if else when API is updated.
                if (Selection == Selection.Minimal)
                {
                       if (_position < ListSize)
                    {
                        //position has reached end of the internal list. But number of directory entries retrieved from last server call is less than list 
                        //size so no more entries are left on server. So even though RemainingEntries is positive, but there is no data in server. Return false
                        return false;
                    }
                    //Else we have to look in server to see if we still have any more directory entries to enumerate
                    //Obtain the last enumerated entry name so that we can retrieve files after that from server
                    ListAfterNext = FileStatus[_position - 1].Name;
                }
                else
                {
                    if (string.IsNullOrEmpty(continuationToken))
                    {
                        //Continuation token is blank or null. No more entries.
                        return false;
                    }
                    else
                    {
                        //Obtain the last enumerated entry name so that we can retrieve files after that from server
                        ListAfterNext = continuationToken;
                    }
                }
                                
            }
            _position = -1;
            OperationResponse resp = new OperationResponse();
            int getListSize = EnumerateAll ? ListSize : Math.Min(ListSize, RemainingEntries);
            // EnumerateDirectoryChangeAclJob also calls core separately. If you change logic here, consider changing there also
            var fileListResult = Core.ListStatusAsync<DirectoryEntryListResult<T>>(Path, ListAfterNext, ListBefore, getListSize, Ugr, Selection, _extraQueryParamsForListStatus, Client, new RequestOptions(Client.GetPerRequestTimeout(), new ExponentialRetryPolicy()), resp, _cancelToken).GetAwaiter().GetResult();
            if (!resp.IsSuccessful)
            {
                throw Client.GetExceptionFromResponse(resp, "Error getting listStatus for path " + Path + " after " + ListAfterNext);
            }
            FileStatus = Core.GetDirectoryEntryListWithFullPath(Path, fileListResult, resp);
            if (!resp.IsSuccessful)
            {
                throw Client.GetExceptionFromResponse(resp, "Unexpected error getting listStatus for path " + Path + " after " + ListAfterNext);
            }
            // Retrieve the continuation token here since above we have checked whether fileListResult. FileStatuses is not null
            continuationToken = fileListResult.FileStatuses.ContinuationToken;

            return MoveNext();
        }