internal QueryOperationResponse GetResponseWithType(MaterializeAtom results, Type elementType) { if (this.httpWebResponse != null) { Dictionary <string, string> headers = WebUtil.WrapResponseHeaders(this.httpWebResponse); QueryOperationResponse response = QueryOperationResponse.GetInstance(elementType, headers, this.ServiceRequest, results); response.StatusCode = (int)this.httpWebResponse.StatusCode; return(response); } return(null); }
/// <summary> /// Returns the response for the request. /// </summary> /// <param name="results">materialized results for the request.</param> /// <param name="elementType">element type of the results.</param> /// <returns>returns the instance of QueryOperationResponse containing the response.</returns> internal QueryOperationResponse GetResponseWithType(MaterializeAtom results, Type elementType) { if (this.responseMessage != null) { HeaderCollection headers = new HeaderCollection(this.responseMessage); QueryOperationResponse response = QueryOperationResponse.GetInstance(elementType, headers, this.ServiceRequest, results); response.StatusCode = (int)this.responseMessage.StatusCode; return response; } return null; }
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; }