Beispiel #1
0
        /// <summary>
        /// Lists result.
        /// </summary>
        /// <param name="cancellationToken"><see cref="CancellationToken"/> to be used for cancellation.</param>
        /// <returns><see cref="TeamsListResult{TTeamsObject}"/> to get result.</returns>
        public async Task <TeamsListResult <TTeamsObject> > ListNextAsync(CancellationToken?cancellationToken = null)
        {
            TeamsListResult <TTeamsObject> result = null;

            if (this.HasNext)
            {
                result = await this.TeamsHttpClient.RequestJsonAsync <TeamsListResult <TTeamsObject>, TTeamsObject>(
                    HttpMethod.Get,
                    this.NextUri,
                    null,
                    null,
                    cancellationToken);

                result.ListTransactionId = this.ListTransactionId;
            }
            else
            {
                result = new TeamsListResult <TTeamsObject>();

                result.Data           = new TTeamsObject();
                result.Data.HasValues = false;
            }

            return(result);
        }
        /// <summary>
        /// Advances the enumerator to the next <see cref="TeamsListResult{TTeamsObject}"/>.
        /// </summary>
        /// <param name="cancellationToken"><see cref="CancellationToken"/> to be used for cancellation.</param>
        /// <returns>true if the enumerator was successfully advanced to the next <see cref="TeamsListResult{TTeamsObject}"/>; false if the enumerator has passed the end of the result.</returns>
        public async Task <bool> MoveNextAsync(CancellationToken?cancellationToken = null)
        {
            bool isMoved = false;

            if (this.CurrentResult == null)
            {
                this.CurrentResult = this.prev;

                isMoved = true;
            }
            else if (this.CurrentResult.HasNext)
            {
                this.prev = this.CurrentResult;

                if (this.retry == null)
                {
                    this.CurrentResult = await this.prev.ListNextAsync(cancellationToken);
                }
                else
                {
                    this.CurrentResult = await this.retry.requestAsync <TeamsListResult <TTeamsObject>, TTeamsObject>(
                        () => (this.prev.ListNextAsync(cancellationToken)),
                        this.retryNotificationFunc,
                        cancellationToken);
                }

                isMoved = true;
            }

            return(isMoved);
        }
        /// <summary>
        /// Constructor of <see cref="TeamsListResultEnumerator{TTeamsObject}"/>.
        /// </summary>
        /// <param name="listResult">First result.</param>
        /// <param name="retry">Retry will be tried by this instance if needed.</param>
        /// <param name="retryNotificationFunc">Function to be notified on retry.</param>
        internal TeamsListResultEnumerator(TeamsListResult <TTeamsObject> listResult, TeamsRetry retry, Func <TeamsListResult <TTeamsObject>, int, bool> retryNotificationFunc = null)
        {
            this.prev = listResult;

            this.retry = retry;
            this.retryNotificationFunc = retryNotificationFunc;
        }
 /// <summary>
 /// Constructor of <see cref="TeamsListResultEnumerator{TTeamsObject}"/>.
 /// </summary>
 /// <param name="listResult">First result.</param>
 internal TeamsListResultEnumerator(TeamsListResult <TTeamsObject> listResult)
     : this(listResult, null, null)
 {
 }