Example #1
0
        public async Task <string> ForEachAsync(string path, bool recursive, bool deleted, Action <FileItem> action)
        {
            const string      logstem     = "ForEachAsync():{0}";
            Action <Metadata> handleEntry = (entry) =>
            {
                var item = FileItem.Create(entry);
                if (item.Path != this.context.RemotePath)
                {
                    action(item);
                }
            };

            var args0 = new ListFolderArg(path, recursive, false, deleted);
            ListFolderResult result = await this.Client.Files
                                      .ListFolderAsync(args0)
                                      .WithTimeout(TimeSpan.FromSeconds(this.context.HttpReadTimeoutInSeconds));

            // These logging calls are very expensive so check we're enabled first
            if (log.IsDebugEnabled)
            {
                log.DebugFormat(logstem, "Request:" + Json.ToString(args0));
                log.DebugFormat(logstem, "Result:" + Json.ToString(result));
            }

            foreach (var entry in result.Entries)
            {
                handleEntry(entry);
            }

            while (result.HasMore)
            {
                var args1 = new ListFolderContinueArg(result.Cursor);
                result = await this.Client.Files
                         .ListFolderContinueAsync(args1)
                         .WithTimeout(TimeSpan.FromSeconds(this.context.HttpReadTimeoutInSeconds));

                if (log.IsDebugEnabled)
                {
                    log.DebugFormat(logstem, "Request:" + Json.ToString(args1));
                    log.DebugFormat(logstem, "Result:" + Json.ToString(result));
                }

                foreach (var entry in result.Entries)
                {
                    handleEntry(entry);
                }
            }

            return(result.Cursor);
        }
        /// <summary>
        /// <para>Begins an asynchronous send to the list folder continue route.</para>
        /// </summary>
        /// <param name="cursor">The cursor returned by your last call to <see
        /// cref="Dropbox.Api.Files.Routes.FilesRoutes.ListFolderAsync" /> or <see
        /// cref="Dropbox.Api.Files.Routes.FilesRoutes.ListFolderContinueAsync" />.</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="callbackState">A user provided object that distinguished this send
        /// from other send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginListFolderContinue(string cursor,
                                                        sys.AsyncCallback callback,
                                                        object callbackState = null)
        {
            var listFolderContinueArg = new ListFolderContinueArg(cursor);

            return this.BeginListFolderContinue(listFolderContinueArg, callback, callbackState);
        }
        /// <summary>
        /// <para>Once a cursor has been retrieved from <see
        /// cref="Dropbox.Api.Files.Routes.FilesRoutes.ListFolderAsync" />, use this to
        /// paginate through all files and retrieve updates to the folder.</para>
        /// </summary>
        /// <param name="cursor">The cursor returned by your last call to <see
        /// cref="Dropbox.Api.Files.Routes.FilesRoutes.ListFolderAsync" /> or <see
        /// cref="Dropbox.Api.Files.Routes.FilesRoutes.ListFolderContinueAsync" />.</param>
        /// <returns>The task that represents the asynchronous send operation. The TResult
        /// parameter contains the response from the server.</returns>
        /// <exception cref="Dropbox.Api.ApiException{ListFolderContinueError}">Thrown if there
        /// is an error processing the request; This will contain a <see
        /// cref="ListFolderContinueError"/>.</exception>
        public t.Task<ListFolderResult> ListFolderContinueAsync(string cursor)
        {
            var listFolderContinueArg = new ListFolderContinueArg(cursor);

            return this.ListFolderContinueAsync(listFolderContinueArg);
        }
        /// <summary>
        /// <para>Begins an asynchronous send to the list folder continue route.</para>
        /// </summary>
        /// <param name="listFolderContinueArg">The request parameters.</param>
        /// <param name="callback">The method to be called when the asynchronous send is
        /// completed.</param>
        /// <param name="state">A user provided object that distinguished this send from other
        /// send requests.</param>
        /// <returns>An object that represents the asynchronous send request.</returns>
        public sys.IAsyncResult BeginListFolderContinue(ListFolderContinueArg listFolderContinueArg, sys.AsyncCallback callback, object state = null)
        {
            var task = this.ListFolderContinueAsync(listFolderContinueArg);

            return enc.Util.ToApm(task, callback, state);
        }
 /// <summary>
 /// <para>Once a cursor has been retrieved from <see
 /// cref="Dropbox.Api.Files.Routes.FilesRoutes.ListFolderAsync" />, use this to
 /// paginate through all files and retrieve updates to the folder.</para>
 /// </summary>
 /// <param name="listFolderContinueArg">The request parameters</param>
 /// <returns>The task that represents the asynchronous send operation. The TResult
 /// parameter contains the response from the server.</returns>
 /// <exception cref="Dropbox.Api.ApiException{ListFolderContinueError}">Thrown if there
 /// is an error processing the request; This will contain a <see
 /// cref="ListFolderContinueError"/>.</exception>
 public t.Task<ListFolderResult> ListFolderContinueAsync(ListFolderContinueArg listFolderContinueArg)
 {
     return this.Transport.SendRpcRequestAsync<ListFolderContinueArg, ListFolderResult, ListFolderContinueError>(listFolderContinueArg, "api", "/files/list_folder/continue", ListFolderContinueArg.Encoder, ListFolderResult.Decoder, ListFolderContinueError.Decoder);
 }