/// <summary> /// Verifies that calling Read is valid. /// </summary> /// <param name="synchronousCall">true if the call is to be synchronous; false otherwise.</param> private void VerifyCanRead(bool synchronousCall) { this.inputContext.VerifyNotDisposed(); this.VerifyCallAllowed(synchronousCall); if (this.State == ODataParameterReaderState.Exception || this.State == ODataParameterReaderState.Completed) { throw new ODataException(Strings.ODataParameterReaderCore_ReadOrReadAsyncCalledInInvalidState(this.State)); } if (this.State == ODataParameterReaderState.Resource || this.State == ODataParameterReaderState.ResourceSet || this.State == ODataParameterReaderState.Collection) { if (this.subReaderState == SubReaderState.None) { throw new ODataException(Strings.ODataParameterReaderCore_SubReaderMustBeCreatedAndReadToCompletionBeforeTheNextReadOrReadAsyncCall(this.State, ODataParameterReaderCore.GetCreateReaderMethodName(this.State))); } else if (this.subReaderState == SubReaderState.Active) { throw new ODataException(Strings.ODataParameterReaderCore_SubReaderMustBeInCompletedStateBeforeTheNextReadOrReadAsyncCall(this.State, ODataParameterReaderCore.GetCreateReaderMethodName(this.State))); } } }
/// <summary> /// Verifies that one of CreateResourceReader(), CreateResourceSetReader() or CreateCollectionReader() can be called. /// </summary> /// <param name="expectedState">The expected state of the reader.</param> private void VerifyCanCreateSubReader(ODataParameterReaderState expectedState) { this.inputContext.VerifyNotDisposed(); if (this.State != expectedState) { throw new ODataException(Strings.ODataParameterReaderCore_InvalidCreateReaderMethodCalledForState(ODataParameterReaderCore.GetCreateReaderMethodName(expectedState), this.State)); } if (this.subReaderState != SubReaderState.None) { Debug.Assert(this.Name != null, "this.Name != null"); throw new ODataException(Strings.ODataParameterReaderCore_CreateReaderAlreadyCalled(ODataParameterReaderCore.GetCreateReaderMethodName(expectedState), this.Name)); } }