Example #1
0
        /// <summary>
        /// worker method for the resumable update
        /// </summary>
        /// <param name="data"></param>
        /// <param name="asyncOp"></param>
        /// <param name="completionMethodDelegate"></param>
        /// <returns></returns>
        private void AsyncUpdateWorker(AsyncResumableUploadData data, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
        {
            try
            {
                AbstractEntry abstractEntry = data.Entry as AbstractEntry;
                if (abstractEntry != null)
                {
                    using (var response = Update(data.Authentication, abstractEntry, data))
                    {
                        HandleResponseStream(data, response.GetResponseStream(), -1);
                    }
                }
                else
                {
                    using (var response = Update(data.Authentication, data.UriToUse, data.DataStream, data.ContentType, data))
                    {
                        HandleResponseStream(data, response.GetResponseStream(), -1);
                    }
                }
            }
            catch (Exception e)
            {
                data.Exception = e;
            }

            CompletionMethodDelegate(data);
        }
Example #2
0
        public void UpdateAsync(Authenticator authentication, AbstractEntry payload, object userData)
        {
            AsyncResumableUploadData data = new AsyncResumableUploadData(
                this,
                authentication,
                payload,
                HttpMethods.Put,
                ProgressReportDelegate,
                userData);
            WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncUpdateWorker);

            AsyncStarter(data, workerDelegate, userData);
        }
Example #3
0
        public void InsertAsync(Authenticator authentication, AbstractEntry payload, object userData)
        {
            AsyncResumableUploadData data = new AsyncResumableUploadData(
                this,
                authentication,
                payload,
                HttpMethods.Post,
                ProgressReportDelegate,
                userData);

            data.UriToUse = GetResumableCreateUri(payload.Links);
            WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncInsertWorker);

            AsyncStarter(data, workerDelegate, userData);
        }
Example #4
0
        /// <summary>
        /// starts the async job
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userData"></param>
        /// <param name="workerDelegate"></param>
        /// <returns></returns>
        private void AsyncStarter(AsyncResumableUploadData data, WorkerResumableUploadHandler workerDelegate, Object userData)
        {
            AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userData);

            data.Operation = asyncOp;

            AddUserDataToDictionary(userData, asyncOp);

            // Start the asynchronous operation.
            workerDelegate.BeginInvoke(
                data,
                asyncOp,
                CompletionMethodDelegate,
                null,
                null);
        }
Example #5
0
        /// <summary>
        /// worker method to handle the resume operation
        /// </summary>
        /// <param name="data"></param>
        /// <param name="asyncOp"></param>
        /// <param name="completionMethodDelegate"></param>
        /// <returns></returns>
        private void AsyncResumeWorker(AsyncResumableUploadData data, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
        {
            try
            {
                using (var response = Resume(data.Authentication, data.UriToUse, data.HttpVerb, data.DataStream, data.ContentType, data))
                {
                    HandleResponseStream(data, response.GetResponseStream(), -1);
                }
            }
            catch (Exception e)
            {
                data.Exception = e;
            }

            CompletionMethodDelegate(data);
        }
Example #6
0
        public void ResumeAsync(Authenticator authentication, Uri resumeUri, String httpmethod, Stream payload, string contentType, object userData)
        {
            AsyncResumableUploadData data = new AsyncResumableUploadData(
                this,
                authentication,
                resumeUri,
                payload,
                contentType,
                null,
                httpmethod,
                ProgressReportDelegate,
                userData);
            WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncResumeWorker);

            AsyncStarter(data, workerDelegate, userData);
        }
Example #7
0
        public void InsertAsync(Authenticator authentication, Uri resumableUploadUri, Stream payload, string contentType, string slug, object userData)
        {
            AsyncResumableUploadData data = new AsyncResumableUploadData(
                this,
                authentication,
                resumableUploadUri,
                payload,
                contentType,
                slug,
                HttpMethods.Post,
                ProgressReportDelegate,
                userData);
            WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncInsertWorker);

            AsyncStarter(data, workerDelegate, userData);
        }