/// <summary> /// Reads the next <see cref="ODataItem"/> from the message payload. /// </summary> /// <returns>true if more items were read; otherwise false.</returns> private bool ReadImplementation() { bool result; switch (this.State) { case ODataReaderState.Start: result = this.ReadAtStartImplementation(); break; case ODataReaderState.FeedStart: result = this.ReadAtFeedStartImplementation(); break; case ODataReaderState.FeedEnd: result = this.ReadAtFeedEndImplementation(); break; case ODataReaderState.EntryStart: this.IncreaseEntryDepth(); result = this.ReadAtEntryStartImplementation(); break; case ODataReaderState.EntryEnd: this.DecreaseEntryDepth(); result = this.ReadAtEntryEndImplementation(); break; case ODataReaderState.NavigationLinkStart: result = this.ReadAtNavigationLinkStartImplementation(); break; case ODataReaderState.NavigationLinkEnd: result = this.ReadAtNavigationLinkEndImplementation(); break; case ODataReaderState.EntityReferenceLink: result = this.ReadAtEntityReferenceLink(); break; case ODataReaderState.Exception: // fall through case ODataReaderState.Completed: throw new ODataException(Strings.ODataReaderCore_NoReadCallsAllowed(this.State)); default: Debug.Assert(false, "Unsupported reader state " + this.State + " detected."); throw new ODataException(Strings.General_InternalError(InternalErrorCodes.ODataReaderCore_ReadImplementation)); } if ((this.State == ODataReaderState.EntryStart || this.State == ODataReaderState.EntryEnd) && this.Item != null) { ReaderValidationUtils.ValidateEntry(this.CurrentEntry); } return(result); }
protected override Task <bool> ReadAsynchronously() { Task <bool> result; switch (this.State) { case ODataReaderState.Start: result = this.ReadAtStartImplementationAsync(); break; case ODataReaderState.FeedStart: result = this.ReadAtFeedStartImplementationAsync(); break; case ODataReaderState.FeedEnd: result = this.ReadAtFeedEndImplementationAsync(); break; case ODataReaderState.EntryStart: result = TaskUtils.GetTaskForSynchronousOperation(() => this.IncreaseEntryDepth()) .FollowOnSuccessWithTask(t => this.ReadAtEntryStartImplementationAsync()); break; case ODataReaderState.EntryEnd: result = TaskUtils.GetTaskForSynchronousOperation(() => this.DecreaseEntryDepth()) .FollowOnSuccessWithTask(t => this.ReadAtEntryEndImplementationAsync()); break; case ODataReaderState.NavigationLinkStart: result = this.ReadAtNavigationLinkStartImplementationAsync(); break; case ODataReaderState.NavigationLinkEnd: result = this.ReadAtNavigationLinkEndImplementationAsync(); break; case ODataReaderState.EntityReferenceLink: result = this.ReadAtEntityReferenceLinkAsync(); break; case ODataReaderState.Exception: // fall through case ODataReaderState.Completed: result = TaskUtils.GetFaultedTask <bool>(new ODataException(Strings.ODataReaderCore_NoReadCallsAllowed(this.State))); break; default: Debug.Assert(false, "Unsupported reader state " + this.State + " detected."); result = TaskUtils.GetFaultedTask <bool>(new ODataException(Strings.General_InternalError(InternalErrorCodes.ODataReaderCoreAsync_ReadAsynchronously))); break; } return(result.FollowOnSuccessWith(t => { if ((this.State == ODataReaderState.EntryStart || this.State == ODataReaderState.EntryEnd) && this.Item != null) { ReaderValidationUtils.ValidateEntry(this.CurrentEntry); } return t.Result; })); }