public Scope(ODataCollectionReaderState state, object item, bool isCollectionElementEmpty) { this.state = state; this.item = item; this.isCollectionElementEmpty = isCollectionElementEmpty; bool flag1 = this.isCollectionElementEmpty; }
protected void PopScope(ODataCollectionReaderState state) { Debug.Assert(this.scopes.Count > 1, "Stack must have more than 1 items in order to pop an item."); Scope scope = this.scopes.Pop(); Debug.Assert(scope.State == state, "scope.State == state"); }
public ODataAvroCollectionReader(ODataAvroInputContext inputContext) { Debug.Assert(inputContext != null, "inputContext != null"); this.reader = inputContext.AvroReader; this.enumerator = null; this.state = ODataCollectionReaderState.Start; }
protected void ReplaceScope(ODataCollectionReaderState state, object item) { if (state == ODataCollectionReaderState.Value) { ValidationUtils.ValidateCollectionItem(item, true); } this.scopes.Pop(); this.EnterScope(state, item); }
/// <summary> /// Replaces the current scope with a new <see cref="Scope"/> with the specified <paramref name="state"/> and /// the item of the current scope. /// </summary> /// <param name="state">The <see cref="ODataCollectionReaderState"/> to use for the new scope.</param> /// <param name="item">The item associated with the replacement state.</param> protected void ReplaceScope(ODataCollectionReaderState state, object item) { Debug.Assert(this.scopes.Count > 0, "Stack must always be non-empty."); if (state == ODataCollectionReaderState.Value) { ValidationUtils.ValidateCollectionItem(item, true /* isNullable */); } this.scopes.Pop(); this.EnterScope(state, item); }
protected void EnterScope(ODataCollectionReaderState state, object item, bool isCollectionElementEmpty) { if (state == ODataCollectionReaderState.Value) { ValidationUtils.ValidateCollectionItem(item, true); } this.scopes.Push(new Scope(state, item, isCollectionElementEmpty)); if (this.listener != null) { if (state == ODataCollectionReaderState.Exception) { this.listener.OnException(); } else if (state == ODataCollectionReaderState.Completed) { this.listener.OnCompleted(); } } }
public Scope(ODataCollectionReaderState state, object item, bool isCollectionElementEmpty) { Debug.Assert( state == ODataCollectionReaderState.Start && item == null || state == ODataCollectionReaderState.CollectionStart && item is ODataCollectionStart || state == ODataCollectionReaderState.Value && (item == null || item is ODataComplexValue || EdmLibraryExtensions.IsPrimitiveType(item.GetType()) || item is ODataEnumValue) || state == ODataCollectionReaderState.CollectionEnd && item is ODataCollectionStart || state == ODataCollectionReaderState.Exception && item == null || state == ODataCollectionReaderState.Completed && item == null, "Reader state and associated item do not match."); this.state = state; this.item = item; this.isCollectionElementEmpty = isCollectionElementEmpty; if (this.isCollectionElementEmpty) { Debug.Assert(state == ODataCollectionReaderState.CollectionStart, "Expected state to be CollectionStart."); } }
private bool ReadImplementation() { switch (this.state) { case ODataCollectionReaderState.Start: if (!this.reader.MoveNext()) { this.state = ODataCollectionReaderState.Completed; return(false); } var collection = this.reader.Current as object[]; if (collection == null) { this.state = ODataCollectionReaderState.Exception; return(false); } this.enumerator = collection.GetEnumerator(); this.state = ODataCollectionReaderState.CollectionStart; break; case ODataCollectionReaderState.CollectionStart: case ODataCollectionReaderState.Value: this.state = this.enumerator.MoveNext() ? ODataCollectionReaderState.Value : ODataCollectionReaderState.CollectionEnd; break; case ODataCollectionReaderState.CollectionEnd: this.state = ODataCollectionReaderState.Completed; return(false); default: throw new ApplicationException("Invalid reader state."); } return(true); }
private bool ReadImplementation() { switch (this.state) { case ODataCollectionReaderState.Start: if (!this.reader.MoveNext()) { this.state = ODataCollectionReaderState.Completed; return false; } var collection = this.reader.Current as object[]; if (collection == null) { this.state = ODataCollectionReaderState.Exception; return false; } this.enumerator = collection.GetEnumerator(); this.state = ODataCollectionReaderState.CollectionStart; break; case ODataCollectionReaderState.CollectionStart: case ODataCollectionReaderState.Value: this.state = this.enumerator.MoveNext() ? ODataCollectionReaderState.Value : ODataCollectionReaderState.CollectionEnd; break; case ODataCollectionReaderState.CollectionEnd: this.state = ODataCollectionReaderState.Completed; return false; default: throw new ApplicationException("Invalid reader state."); } return true; }
public Scope(ODataCollectionReaderState state, object item) : this(state, item, false) { }
/// <summary> /// Creates a new <see cref="Scope"/> for the specified <paramref name="state"/> and /// with the provided <paramref name="item"/> and pushes it on the stack of scopes. /// </summary> /// <param name="state">The <see cref="ODataCollectionReaderState"/> to use for the new scope.</param> /// <param name="item">The item to attach with the state in the new scope.</param> protected void EnterScope(ODataCollectionReaderState state, object item) { this.EnterScope(state, item, false); }
protected void PopScope(ODataCollectionReaderState state) { this.scopes.Pop(); }