Esempio n. 1
0
 public CosResponse(CosResult cosResult, string saveFilePath, long saveFileOffset, COSXML.Callback.OnProgressCallback downloadProgressCallback,
                    COSXML.Callback.OnSuccessCallback <CosResult> successCallback,
                    COSXML.Callback.OnFailedCallback failCallback) : this(cosResult, saveFilePath, saveFileOffset, downloadProgressCallback)
 {
     this.successCallback = successCallback;
     this.faileCallback   = failCallback;
 }
Esempio n. 2
0
 public void Schedue(CosRequest cosRequest, CosResult cosResult, COSXML.Callback.OnSuccessCallback <CosResult> successCallback,
                     COSXML.Callback.OnFailedCallback failCallback)
 {
     //HttpTask httpTask = new HttpTask();
     //httpTask.cosRequest = cosRequest;
     //httpTask.cosResult = cosResult;
     //httpTask.isSchedue = true;
     //httpTask.successCallback = successCallback;
     //httpTask.failCallback = failCallback;
     InternalSchedue(cosRequest, cosResult, successCallback, failCallback);
 }
Esempio n. 3
0
        private TaskCompletionSource <T> NewTaskCompletion <T>() where T : CosResult
        {
            var t = new TaskCompletionSource <T>();

            successCallback = delegate(CosResult cosResult)
            {
                t.TrySetResult(cosResult as T);
            };

            failCallback = delegate(CosClientException clientException, CosServerException serverException)
            {
                if (clientException != null)
                {
                    t.TrySetException(clientException);
                }
                else
                {
                    t.TrySetException(serverException);
                }
            };

            return(t);
        }
Esempio n. 4
0
 public void Schedue(CosRequest cosRequest, CosResult cosResult, COSXML.Callback.OnSuccessCallback <CosResult> successCallback,
                     COSXML.Callback.OnFailedCallback failCallback)
 {
     try
     {
         Request  request = CreateRequest(cosRequest);
         Response response;
         if (cosRequest is GetObjectRequest)
         {
             GetObjectRequest getObjectRequest = cosRequest as GetObjectRequest;
             response = new CosResponse(cosResult, getObjectRequest.GetSaveFilePath(), getObjectRequest.GetLocalFileOffset(),
                                        getObjectRequest.GetCosProgressCallback(), successCallback, failCallback);
         }
         else
         {
             response = new CosResponse(cosResult, null, -1L, null, successCallback, failCallback);
         }
         cosRequest.BindRequest(request);
         CommandTask.Schedue(request, response, config);
     }
     catch (CosServerException serverException)
     {
         //throw serverException;
         failCallback(null, serverException);
     }
     catch (CosClientException clientException)
     {
         //throw clientException;
         failCallback(clientException, null);
     }
     catch (Exception ex)
     {
         //throw new CosClientException((int)CosClientError.BAD_REQUEST, ex.Message, ex);
         failCallback(new CosClientException((int)CosClientError.BAD_REQUEST, ex.Message, ex), null);
     }
 }
Esempio n. 5
0
 public void GetService(Model.Service.GetServiceRequest request, COSXML.Callback.OnSuccessCallback <CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback)
 {
     schedue(request, new GetServiceResult(), successCallback, failCallback);
 }
Esempio n. 6
0
 private void schedue(CosRequest request, CosResult result, COSXML.Callback.OnSuccessCallback <CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback)
 {
     CheckAppidAndRegion(request);
     httpClient.Schedue(request, result, successCallback, failCallback);
 }
Esempio n. 7
0
 public void PutBucket(PutBucketRequest request, COSXML.Callback.OnSuccessCallback <CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback)
 {
     schedue(request, new PutBucketResult(), successCallback, failCallback);
 }