protected override DataServiceResponse HandleResponse() { List <OperationResponse> list = new List <OperationResponse>((this.cachedResponses != null) ? this.cachedResponses.Count : 0); DataServiceResponse response = new DataServiceResponse(null, -1, list, false); Exception innerException = null; try { foreach (CachedResponse response2 in this.cachedResponses) { Descriptor descriptor = response2.Descriptor; base.SaveResultProcessed(descriptor); OperationResponse item = new ChangeOperationResponse(response2.Headers, descriptor) { StatusCode = (int)response2.StatusCode }; if (response2.Exception != null) { item.Error = response2.Exception; if (innerException == null) { innerException = response2.Exception; } } else { this.cachedResponse = response2; base.HandleOperationResponse(descriptor, response2.Headers); } list.Add(item); } } catch (InvalidOperationException exception2) { innerException = exception2; } if (innerException != null) { throw new DataServiceRequestException(System.Data.Services.Client.Strings.DataServiceException_GeneralError, innerException, response); } return(response); }
private IEnumerable <OperationResponse> HandleBatchResponse(ODataBatchReader batchReader) { if (this.batchMessageReader == null) { goto Label_056D; } bool iteratorVariable0 = false; bool iteratorVariable1 = false; int index = 0; int iteratorVariable3 = 0; this.entryIndex = 0; Label_PostSwitchInIterator :; while (batchReader.Read()) { Exception iteratorVariable4; switch (batchReader.State) { case ODataBatchReaderState.Operation: { iteratorVariable4 = this.ProcessCurrentOperationResponse(batchReader); if (iteratorVariable1) { break; } QueryOperationResponse iteratorVariable5 = null; try { if (iteratorVariable4 == null) { DataServiceRequest query = this.Queries[index]; MaterializeAtom results = DataServiceRequest.Materialize(this.RequestInfo.GetDeserializationInfo(null), query.QueryComponents(this.RequestInfo.MaxProtocolVersion), null, this.currentOperationResponse.GetHeader("Content-Type"), this.currentOperationResponse.CreateResponseMessage(), query.PayloadKind); iteratorVariable5 = QueryOperationResponse.GetInstance(query.ElementType, this.currentOperationResponse.Headers, query, results); } } catch (ArgumentException exception) { iteratorVariable4 = exception; } catch (FormatException exception2) { iteratorVariable4 = exception2; } catch (InvalidOperationException exception3) { iteratorVariable4 = exception3; } if (iteratorVariable5 == null) { if (this.Queries == null) { throw iteratorVariable4; } DataServiceRequest request2 = this.Queries[index]; if (this.RequestInfo.IgnoreResourceNotFoundException && (this.currentOperationResponse.StatusCode == HttpStatusCode.NotFound)) { iteratorVariable5 = QueryOperationResponse.GetInstance(request2.ElementType, this.currentOperationResponse.Headers, request2, MaterializeAtom.EmptyResults); } else { iteratorVariable5 = QueryOperationResponse.GetInstance(request2.ElementType, this.currentOperationResponse.Headers, request2, MaterializeAtom.EmptyResults); iteratorVariable5.Error = iteratorVariable4; } } iteratorVariable5.StatusCode = (int)this.currentOperationResponse.StatusCode; index++; yield return(iteratorVariable5); goto Label_PostSwitchInIterator; } case ODataBatchReaderState.ChangesetStart: { if ((this.IsBatch && iteratorVariable0) || (iteratorVariable3 != 0)) { System.Data.Services.Client.Error.ThrowBatchUnexpectedContent(InternalError.UnexpectedBeginChangeSet); } iteratorVariable1 = true; continue; } case ODataBatchReaderState.ChangesetEnd: { iteratorVariable0 = true; iteratorVariable3 = 0; iteratorVariable1 = false; continue; } default: goto Label_0491; } this.entryIndex = this.ValidateContentID(this.currentOperationResponse.Headers); try { Descriptor descriptor = this.ChangedEntries[this.entryIndex]; iteratorVariable3 += this.SaveResultProcessed(descriptor); if (iteratorVariable4 != null) { throw iteratorVariable4; } this.HandleOperationResponseHeaders(this.currentOperationResponse.StatusCode, this.currentOperationResponse.Headers); this.HandleOperationResponse(descriptor, this.currentOperationResponse.Headers); } catch (Exception exception4) { this.ChangedEntries[this.entryIndex].SaveError = exception4; iteratorVariable4 = exception4; if (!CommonUtil.IsCatchableExceptionType(exception4)) { throw; } } ChangeOperationResponse iteratorVariable6 = new ChangeOperationResponse(this.currentOperationResponse.Headers, this.ChangedEntries[this.entryIndex]) { StatusCode = (int)this.currentOperationResponse.StatusCode }; if (iteratorVariable4 != null) { iteratorVariable6.Error = iteratorVariable4; } iteratorVariable3++; this.entryIndex++; yield return(iteratorVariable6); goto Label_PostSwitchInIterator; Label_0491: System.Data.Services.Client.Error.ThrowBatchExpectedResponse(InternalError.UnexpectedBatchState); } if (((this.Queries == null) && ((!iteratorVariable0 || (0 < index)) || (this.ChangedEntries.Any <Descriptor>(o => (o.ContentGeneratedForSave && (o.SaveResultWasProcessed == 0))) && (!this.IsBatch || (this.ChangedEntries.FirstOrDefault <Descriptor>(o => (o.SaveError != null)) == null))))) || ((this.Queries != null) && (index != this.Queries.Length))) { throw System.Data.Services.Client.Error.InvalidOperation(System.Data.Services.Client.Strings.Batch_IncompleteResponseCount); } Label_056D: yield break; }
private IEnumerable<OperationResponse> HandleBatchResponse(ODataBatchReader batchReader) { if (this.batchMessageReader == null) { goto Label_056D; } bool iteratorVariable0 = false; bool iteratorVariable1 = false; int index = 0; int iteratorVariable3 = 0; this.entryIndex = 0; Label_PostSwitchInIterator:; while (batchReader.Read()) { Exception iteratorVariable4; switch (batchReader.State) { case ODataBatchReaderState.Operation: { iteratorVariable4 = this.ProcessCurrentOperationResponse(batchReader); if (iteratorVariable1) { break; } QueryOperationResponse iteratorVariable5 = null; try { if (iteratorVariable4 == null) { DataServiceRequest query = this.Queries[index]; MaterializeAtom results = DataServiceRequest.Materialize(this.RequestInfo.GetDeserializationInfo(null), query.QueryComponents(this.RequestInfo.MaxProtocolVersion), null, this.currentOperationResponse.GetHeader("Content-Type"), this.currentOperationResponse.CreateResponseMessage(), query.PayloadKind); iteratorVariable5 = QueryOperationResponse.GetInstance(query.ElementType, this.currentOperationResponse.Headers, query, results); } } catch (ArgumentException exception) { iteratorVariable4 = exception; } catch (FormatException exception2) { iteratorVariable4 = exception2; } catch (InvalidOperationException exception3) { iteratorVariable4 = exception3; } if (iteratorVariable5 == null) { if (this.Queries == null) { throw iteratorVariable4; } DataServiceRequest request2 = this.Queries[index]; if (this.RequestInfo.IgnoreResourceNotFoundException && (this.currentOperationResponse.StatusCode == HttpStatusCode.NotFound)) { iteratorVariable5 = QueryOperationResponse.GetInstance(request2.ElementType, this.currentOperationResponse.Headers, request2, MaterializeAtom.EmptyResults); } else { iteratorVariable5 = QueryOperationResponse.GetInstance(request2.ElementType, this.currentOperationResponse.Headers, request2, MaterializeAtom.EmptyResults); iteratorVariable5.Error = iteratorVariable4; } } iteratorVariable5.StatusCode = (int) this.currentOperationResponse.StatusCode; index++; yield return iteratorVariable5; goto Label_PostSwitchInIterator; } case ODataBatchReaderState.ChangesetStart: { if ((this.IsBatch && iteratorVariable0) || (iteratorVariable3 != 0)) { System.Data.Services.Client.Error.ThrowBatchUnexpectedContent(InternalError.UnexpectedBeginChangeSet); } iteratorVariable1 = true; continue; } case ODataBatchReaderState.ChangesetEnd: { iteratorVariable0 = true; iteratorVariable3 = 0; iteratorVariable1 = false; continue; } default: goto Label_0491; } this.entryIndex = this.ValidateContentID(this.currentOperationResponse.Headers); try { Descriptor descriptor = this.ChangedEntries[this.entryIndex]; iteratorVariable3 += this.SaveResultProcessed(descriptor); if (iteratorVariable4 != null) { throw iteratorVariable4; } this.HandleOperationResponseHeaders(this.currentOperationResponse.StatusCode, this.currentOperationResponse.Headers); this.HandleOperationResponse(descriptor, this.currentOperationResponse.Headers); } catch (Exception exception4) { this.ChangedEntries[this.entryIndex].SaveError = exception4; iteratorVariable4 = exception4; if (!CommonUtil.IsCatchableExceptionType(exception4)) { throw; } } ChangeOperationResponse iteratorVariable6 = new ChangeOperationResponse(this.currentOperationResponse.Headers, this.ChangedEntries[this.entryIndex]) { StatusCode = (int) this.currentOperationResponse.StatusCode }; if (iteratorVariable4 != null) { iteratorVariable6.Error = iteratorVariable4; } iteratorVariable3++; this.entryIndex++; yield return iteratorVariable6; goto Label_PostSwitchInIterator; Label_0491: System.Data.Services.Client.Error.ThrowBatchExpectedResponse(InternalError.UnexpectedBatchState); } if (((this.Queries == null) && ((!iteratorVariable0 || (0 < index)) || (this.ChangedEntries.Any<Descriptor>(o => (o.ContentGeneratedForSave && (o.SaveResultWasProcessed == 0))) && (!this.IsBatch || (this.ChangedEntries.FirstOrDefault<Descriptor>(o => (o.SaveError != null)) == null))))) || ((this.Queries != null) && (index != this.Queries.Length))) { throw System.Data.Services.Client.Error.InvalidOperation(System.Data.Services.Client.Strings.Batch_IncompleteResponseCount); } Label_056D: yield break; }
protected override DataServiceResponse HandleResponse() { List<OperationResponse> list = new List<OperationResponse>((this.cachedResponses != null) ? this.cachedResponses.Count : 0); DataServiceResponse response = new DataServiceResponse(null, -1, list, false); Exception innerException = null; try { foreach (CachedResponse response2 in this.cachedResponses) { Descriptor descriptor = response2.Descriptor; base.SaveResultProcessed(descriptor); OperationResponse item = new ChangeOperationResponse(response2.Headers, descriptor) { StatusCode = (int) response2.StatusCode }; if (response2.Exception != null) { item.Error = response2.Exception; if (innerException == null) { innerException = response2.Exception; } } else { this.cachedResponse = response2; base.HandleOperationResponse(descriptor, response2.Headers); } list.Add(item); } } catch (InvalidOperationException exception2) { innerException = exception2; } if (innerException != null) { throw new DataServiceRequestException(System.Data.Services.Client.Strings.DataServiceException_GeneralError, innerException, response); } return response; }