Ejemplo n.º 1
0
        internal void CreateNextChange()
        {
            ODataRequestMessageWrapper requestMessage = null;

            do
            {
                HttpWebResponse response = null;
                try
                {
                    requestMessage = this.CreateNextRequest();
                    if (((requestMessage != null) || (base.entryIndex < base.ChangedEntries.Count)) && !base.ChangedEntries[base.entryIndex].ContentGeneratedForSave)
                    {
                        BaseAsyncResult.ContentStream stream = this.CreateNonBatchChangeData(base.entryIndex, requestMessage);
                        if ((stream != null) && (stream.Stream != null))
                        {
                            if (stream.IsKnownMemoryStream)
                            {
                                requestMessage.SetContentLengthHeader();
                            }
                            using (Stream stream2 = WebUtil.GetRequestStream(requestMessage, (DataServiceContext)base.Source))
                            {
                                int    num;
                                byte[] buffer = new byte[0x10000];
                                do
                                {
                                    num = stream.Stream.Read(buffer, 0, buffer.Length);
                                    if (num > 0)
                                    {
                                        stream2.Write(buffer, 0, num);
                                    }
                                }while (num > 0);
                            }
                        }
                        response = WebUtil.GetResponse(requestMessage, (DataServiceContext)base.Source, false);
                        this.HandleOperationResponse(response);
                        base.HandleOperationResponseHeaders(response.StatusCode, WebUtil.WrapResponseHeaders(response));
                        this.HandleOperationResponseData(response);
                        base.perRequest = null;
                    }
                }
                catch (InvalidOperationException exception)
                {
                    WebUtil.GetHttpWebResponse(exception, ref response);
                    this.HandleOperationException(exception, response);
                }
                finally
                {
                    if (response != null)
                    {
                        response.Close();
                    }
                }
            }while ((base.entryIndex < base.ChangedEntries.Count) && !base.IsCompletedInternally);
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
0
 internal QueryResult(object source, string method, DataServiceRequest serviceRequest, ODataRequestMessageWrapper request, System.Data.Services.Client.RequestInfo requestInfo, AsyncCallback callback, object state, BaseAsyncResult.ContentStream requestContentStream) : this(source, method, serviceRequest, request, requestInfo, callback, state)
 {
     this.requestContentStream = requestContentStream;
 }