Beispiel #1
0
 internal void BatchBeginRequest()
 {
     BaseAsyncResult.PerRequest pereq = null;
     try
     {
         ODataRequestMessageWrapper request = this.GenerateBatchRequest();
         if (request != null)
         {
             request.SetContentLengthHeader();
             base.perRequest = pereq = new BaseAsyncResult.PerRequest();
             pereq.Request = request;
             pereq.RequestContentStream = new BaseAsyncResult.ContentStream(request.CachedRequestStream, true);
             BaseAsyncResult.AsyncStateBag state = new BaseAsyncResult.AsyncStateBag(pereq, (DataServiceContext) base.Source);
             this.responseStream = new MemoryStream();
             IAsyncResult result = BaseAsyncResult.InvokeAsync(new Func<ODataRequestMessageWrapper, AsyncCallback, object, IAsyncResult>(WebUtil.BeginGetRequestStream), request, new AsyncCallback(this.AsyncEndGetRequestStream), state);
             pereq.SetRequestCompletedSynchronously(result.CompletedSynchronously);
         }
     }
     catch (Exception exception)
     {
         base.HandleFailure(pereq, exception);
         throw;
     }
     finally
     {
         this.HandleCompleted(pereq);
     }
 }
Beispiel #2
0
 /// <summary>Set the AsyncWait and invoke the user callback.</summary>
 /// <param name="pereq">the request object</param>
 /// <remarks>This method is not implemented for this class.</remarks>
 protected override void HandleCompleted(BaseAsyncResult.PerRequest pereq)
 {
     Debug.Assert(false, "This method should never be called from GetReadStreamResult.");
     Error.ThrowInternalError(InternalError.InvalidHandleCompleted);
 }
Beispiel #3
0
 internal void BeginCreateNextChange()
 {
     HttpWebResponse response;
     this.inMemoryResponseStream = new MemoryStream();
     BaseAsyncResult.PerRequest pereq = null;
     IAsyncResult result = null;
 Label_000F:
     response = null;
     ODataRequestMessageWrapper requestMessage = null;
     try
     {
         if (base.perRequest != null)
         {
             base.SetCompleted();
             System.Data.Services.Client.Error.ThrowInternalError(InternalError.InvalidBeginNextChange);
         }
         requestMessage = this.CreateNextRequest();
         if (requestMessage == null)
         {
             base.Abortable = null;
         }
         if ((requestMessage != null) || (base.entryIndex < base.ChangedEntries.Count))
         {
             if (base.ChangedEntries[base.entryIndex].ContentGeneratedForSave)
             {
                 goto Label_0191;
             }
             base.Abortable = requestMessage;
             BaseAsyncResult.ContentStream stream = this.CreateNonBatchChangeData(base.entryIndex, requestMessage);
             base.perRequest = pereq = new BaseAsyncResult.PerRequest();
             pereq.Request = requestMessage;
             BaseAsyncResult.AsyncStateBag state = new BaseAsyncResult.AsyncStateBag(pereq, (DataServiceContext) base.Source);
             if ((stream == null) || (stream.Stream == null))
             {
                 result = BaseAsyncResult.InvokeAsync(new Func<ODataRequestMessageWrapper, AsyncCallback, object, IAsyncResult>(WebUtil.BeginGetResponse), requestMessage, new AsyncCallback(this.AsyncEndGetResponse), state);
             }
             else
             {
                 if (stream.IsKnownMemoryStream)
                 {
                     requestMessage.SetContentLengthHeader();
                 }
                 pereq.RequestContentStream = stream;
                 result = BaseAsyncResult.InvokeAsync(new Func<ODataRequestMessageWrapper, AsyncCallback, object, IAsyncResult>(WebUtil.BeginGetRequestStream), requestMessage, new AsyncCallback(this.AsyncEndGetRequestStream), state);
             }
             pereq.SetRequestCompletedSynchronously(result.CompletedSynchronously);
             base.SetCompletedSynchronously(pereq.RequestCompletedSynchronously);
         }
         else
         {
             base.SetCompleted();
             if (base.CompletedSynchronously)
             {
                 this.HandleCompleted(pereq);
             }
         }
     }
     catch (InvalidOperationException exception)
     {
         WebUtil.GetHttpWebResponse(exception, ref response);
         this.HandleOperationException(exception, response);
         this.HandleCompleted(pereq);
     }
     finally
     {
         if (response != null)
         {
             response.Close();
         }
     }
     if (((pereq != null) && pereq.RequestCompleted) && (pereq.RequestCompletedSynchronously && !base.IsCompletedInternally))
     {
         this.FinishCurrentChange(pereq);
     }
 Label_0191:
     if (((pereq == null) || (pereq.RequestCompleted && pereq.RequestCompletedSynchronously)) && !base.IsCompletedInternally)
     {
         goto Label_000F;
     }
 }
Beispiel #4
0
 internal AsyncReadState(BaseAsyncResult.PerRequest pereq)
 {
     this.Pereq = pereq;
     this.totalByteCopied = 0;
 }