Ejemplo n.º 1
0
 private void ExpectState(ODataReaderState expectedState)
 {
     if (this.reader.State != expectedState)
     {
         throw System.Data.Services.Client.Error.InternalError(InternalError.UnexpectedReadState);
     }
 }
 /// <summary>
 /// Asserts the reader is in the expected state.
 /// </summary>
 /// <param name="expectedState">The expected state.</param>
 private void ExpectState(ODataReaderState expectedState)
 {
     if (this.reader.State != expectedState)
     {
         throw DSClient.Error.InternalError(InternalError.UnexpectedReadState);
     }
 }
Ejemplo n.º 3
0
            internal Scope(ODataReaderState state, ODataItem item, IEdmNavigationSource navigationSource, IEdmStructuredType expectedResourceType, ODataUri odataUri)
            {
                Debug.Assert(
                    state == ODataReaderState.Exception && item == null ||
                    state == ODataReaderState.ResourceStart && (item == null || item is ODataResource) ||
                    state == ODataReaderState.ResourceEnd && (item is ODataResource || item == null) ||
                    state == ODataReaderState.Primitive && (item == null || item is ODataPrimitiveValue) ||
                    state == ODataReaderState.ResourceSetStart && item is ODataResourceSet ||
                    state == ODataReaderState.ResourceSetEnd && item is ODataResourceSet ||
                    state == ODataReaderState.NestedResourceInfoStart && item is ODataNestedResourceInfo ||
                    state == ODataReaderState.NestedResourceInfoEnd && item is ODataNestedResourceInfo ||
                    state == ODataReaderState.EntityReferenceLink && item is ODataEntityReferenceLink ||
                    state == ODataReaderState.DeletedResourceStart && (item == null || item is ODataDeletedResource) ||
                    state == ODataReaderState.DeletedResourceEnd && (item is ODataDeletedResource || item == null) ||
                    state == ODataReaderState.DeltaResourceSetStart && item is ODataDeltaResourceSet ||
                    state == ODataReaderState.DeltaResourceSetEnd && item is ODataDeltaResourceSet ||
                    state == ODataReaderState.DeltaLink && (item == null || item is ODataDeltaLink) ||
                    state == ODataReaderState.DeltaDeletedLink && (item == null || item is ODataDeltaDeletedLink) ||
                    state == ODataReaderState.Start && item == null ||
                    state == ODataReaderState.Completed && item == null,
                    "Reader state and associated item do not match.");

                this.state            = state;
                this.item             = item;
                this.ResourceType     = expectedResourceType;
                this.NavigationSource = navigationSource;
                this.odataUri         = odataUri;
            }
Ejemplo n.º 4
0
            internal Scope(ODataReaderState state, ODataItem item, ODataUri odataUri)
            {
                Debug.Assert(
                    state == ODataReaderState.Exception && item == null ||
                    state == ODataReaderState.ResourceStart && (item == null || item is ODataResource) ||
                    state == ODataReaderState.ResourceEnd && (item is ODataResource || item == null) ||
                    state == ODataReaderState.Primitive && (item == null || item is ODataPrimitiveValue || item is ODataNullValue) ||
                    state == ODataReaderState.Stream && (item == null || item is ODataStreamItem) ||
                    state == ODataReaderState.NestedProperty && (item == null || item is ODataPropertyInfo) ||
                    state == ODataReaderState.ResourceSetStart && item is ODataResourceSet ||
                    state == ODataReaderState.ResourceSetEnd && item is ODataResourceSet ||
                    state == ODataReaderState.NestedResourceInfoStart && item is ODataNestedResourceInfo ||
                    state == ODataReaderState.NestedResourceInfoEnd && item is ODataNestedResourceInfo ||
                    state == ODataReaderState.EntityReferenceLink && item is ODataEntityReferenceLink ||
                    state == ODataReaderState.DeletedResourceStart && (item == null || item is ODataDeletedResource) ||
                    state == ODataReaderState.DeletedResourceEnd && (item is ODataDeletedResource || item == null) ||
                    state == ODataReaderState.DeltaResourceSetStart && item is ODataDeltaResourceSet ||
                    state == ODataReaderState.DeltaResourceSetEnd && item is ODataDeltaResourceSet ||
                    state == ODataReaderState.DeltaLink && (item == null || item is ODataDeltaLink) ||
                    state == ODataReaderState.DeltaDeletedLink && (item == null || item is ODataDeltaDeletedLink) ||
                    state == ODataReaderState.Start && item == null ||
                    state == ODataReaderState.Completed && item == null,
                    "Reader state and associated item do not match.");

                this.state    = state;
                this.item     = item;
                this.odataUri = odataUri;
            }
Ejemplo n.º 5
0
        protected void PopScope(ODataReaderState 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");
        }
Ejemplo n.º 6
0
        public ODataVCardReader(VCardInputContext inputContext)
        {
            Debug.Assert(inputContext != null, "inputContext != null");

            this.reader = inputContext.VCardReader;
            this.item   = null;
            this.state  = ODataReaderState.Start;
            this.throwExceptionOnDuplicatedPropertyNames = inputContext.ThrowExceptionOnDuplicatedPropertyNames;
        }
Ejemplo n.º 7
0
 private bool ReadResourceFromRecord(object record)
 {
     this.item = ODataAvroConvert.ToODataEntry(record as AvroRecord);
     if (record == null)
     {
         this.state = ODataReaderState.Exception;
         return(false);
     }
     return(true);
 }
Ejemplo n.º 8
0
            public bool Read()
            {
                if (this.feedEntries != null)
                {
                    if (this.feedEntries.MoveNext())
                    {
                        this.currentEntry = this.feedEntries.Current;
                        return(true);
                    }
                    this.feedEntries  = null;
                    this.currentEntry = null;
                }
                ODataReaderState state = this.reader.State;

                switch (state)
                {
                case ODataReaderState.Start:
                    ODataFeed         feed;
                    MaterializerEntry entry;
                    if (!this.TryReadFeedOrEntry(true, out feed, out entry))
                    {
                        throw new NotImplementedException();
                    }
                    this.currentEntry = (entry != null) ? entry.Entry : null;
                    this.currentFeed  = feed;
                    if (this.currentFeed != null)
                    {
                        this.feedEntries = MaterializerFeed.GetFeed(this.currentFeed).Entries.GetEnumerator();
                    }
                    return(true);

                case ODataReaderState.FeedStart:
                case ODataReaderState.EntryStart:
                    break;

                case ODataReaderState.FeedEnd:
                case ODataReaderState.EntryEnd:
                    if (this.TryRead() || (this.reader.State != ODataReaderState.Completed))
                    {
                        throw System.Data.Services.Client.Error.InternalError(InternalError.UnexpectedReadState);
                    }
                    this.currentEntry = null;
                    return(false);

                default:
                    if (state != ODataReaderState.Completed)
                    {
                        break;
                    }
                    this.currentEntry = null;
                    return(false);
                }
                throw System.Data.Services.Client.Error.InternalError(InternalError.UnexpectedReadState);
            }
Ejemplo n.º 9
0
        public ODataAvroReader(ODataAvroInputContext inputContext, bool readingFeed, object currentObject = null)
        {
            Debug.Assert(inputContext != null, "inputContext != null");

            this.reader        = inputContext.AvroReader;
            this.readingFeed   = readingFeed;
            this.currentObject = currentObject;

            this.item             = null;
            this.recordEnumerator = null;
            this.state            = ODataReaderState.Start;
        }
Ejemplo n.º 10
0
        public ODataAvroReader(ODataAvroInputContext inputContext, bool readingFeed, object currentObject = null)
        {
            Debug.Assert(inputContext != null, "inputContext != null");

            this.reader = inputContext.AvroReader;
            this.readingFeed = readingFeed;
            this.currentObject = currentObject;

            this.item = null;
            this.recordEnumerator = null;
            this.state = ODataReaderState.Start;
        }
Ejemplo n.º 11
0
        private bool MoveToNextAndReadResource()
        {
            if (this.recordEnumerator.MoveNext())
            {
                this.state = ODataReaderState.ResourceStart;
                ReadResourceFromRecord(this.recordEnumerator.Current);
            }
            else
            {
                this.state = ODataReaderState.ResourceSetEnd;
            }

            return(true);
        }
Ejemplo n.º 12
0
            internal Scope(ODataReaderState state, ODataItem item, IEdmEntityType expectedEntityType)
            {
                Debug.Assert(
                    state == ODataReaderState.Exception && item == null ||
                    state == ODataReaderState.EntryStart && (item == null || item is ODataEntry) ||
                    state == ODataReaderState.EntryEnd && (item == null || item is ODataEntry) ||
                    state == ODataReaderState.FeedStart && item is ODataFeed ||
                    state == ODataReaderState.FeedEnd && item is ODataFeed ||
                    state == ODataReaderState.NavigationLinkStart && item is ODataNavigationLink ||
                    state == ODataReaderState.NavigationLinkEnd && item is ODataNavigationLink ||
                    state == ODataReaderState.EntityReferenceLink && item is ODataEntityReferenceLink ||
                    state == ODataReaderState.Start && item == null ||
                    state == ODataReaderState.Completed && item == null,
                    "Reader state and associated item do not match.");

                this.state      = state;
                this.item       = item;
                this.EntityType = expectedEntityType;
            }
Ejemplo n.º 13
0
        private bool DefaultRead()
        {
            if (this.enumerator == null)
            {
                this.enumerator = this.items.GetEnumerator();
            }

            bool hasRead = this.enumerator.MoveNext();
            if (hasRead)
            {
                this.currentState = this.enumerator.Current.State;
                this.currentItem = this.enumerator.Current.Item;
            }
            else
            {
                this.currentState = ODataReaderState.Completed;
                this.currentItem = null;
            }

            return hasRead;
        }
Ejemplo n.º 14
0
        private bool DefaultRead()
        {
            if (this.enumerator == null)
            {
                this.enumerator = this.items.GetEnumerator();
            }

            bool hasRead = this.enumerator.MoveNext();

            if (hasRead)
            {
                this.currentState = this.enumerator.Current.State;
                this.currentItem  = this.enumerator.Current.Item;
            }
            else
            {
                this.currentState = ODataReaderState.Completed;
                this.currentItem  = null;
            }

            return(hasRead);
        }
Ejemplo n.º 15
0
 private void EnterScope(ODataReaderState state, ODataItem item, IEdmEntityType expectedEntityType)
 {
     base.EnterScope(new JsonScope(state, item, expectedEntityType));
 }
Ejemplo n.º 16
0
        public override bool Read()
        {
            switch (this.state)
            {
            case ODataReaderState.Start:
                List <VCardItem> items = new List <VCardItem>();
                this.reader.Read();
                this.reader.Read();
                while (this.reader.State == VCardReaderState.Item)
                {
                    VCardItem vCardItem = new VCardItem()
                    {
                        Name   = this.reader.Name,
                        Value  = this.reader.Value,
                        Groups = this.reader.Groups,
                    };

                    if (this.reader.Params != null)
                    {
                        vCardItem.Params = new Dictionary <string, string>();
                        foreach (string param in this.reader.Params.Split(';'))
                        {
                            int idx = param.IndexOf('=');
                            if (idx >= 0)
                            {
                                // need to care about when = appear in last.
                                vCardItem.Params.Add(param.Substring(0, idx), param.Substring(idx + 1));
                            }
                            else
                            {
                                if (vCardItem.Params.ContainsKey("TYPE"))
                                {
                                    vCardItem.Params["TYPE"] = vCardItem.Params["TYPE"] + ";" + param;
                                }
                                else
                                {
                                    vCardItem.Params.Add("TYPE", param);
                                }
                            }
                        }
                    }

                    items.Add(vCardItem);
                    this.reader.Read();
                }

                Debug.Assert(this.reader.State == VCardReaderState.End);

                this.item  = GetEntryFromItems(items);
                this.state = ODataReaderState.ResourceEnd;
                break;

            case ODataReaderState.ResourceEnd:
                this.state = ODataReaderState.Completed;
                return(false);

            default:
                throw new ApplicationException("Invalid state");
            }

            return(true);
        }
        /// <summary>
        /// Reads from the reader and asserts the reader is in the expected state.
        /// </summary>
        /// <param name="expectedState">The expected state.</param>
        private void ReadAndExpectState(ODataReaderState expectedState)
        {
            this.AssertRead();

            this.ExpectState(expectedState);
        }
Ejemplo n.º 18
0
 protected void PopScope(ODataReaderState state)
 {
     this.scopes.Pop();
 }
Ejemplo n.º 19
0
 private void EnterScope(ODataReaderState state, ODataItem item, IEdmEntityType expectedEntityType)
 {
     base.EnterScope(new AtomScope(state, item, expectedEntityType));
 }
Ejemplo n.º 20
0
 private void ReplaceScope(ODataReaderState state)
 {
     base.ReplaceScope(new AtomScope(state, this.Item, base.CurrentEntityType));
 }
Ejemplo n.º 21
0
 private void WriteEnd(ODataWriter writer, ODataReaderState expectedState)
 {
     this.expectedStates.Add(expectedState);
     writer.WriteEnd();
     writer.Flush();
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Replaces the current scope with a new <see cref="AtomScope"/> with the specified <paramref name="state"/> and
 /// the item of the current scope.
 /// </summary>
 /// <param name="state">The <see cref="ODataReaderState"/> to use for the new scope.</param>
 private void ReplaceScope(ODataReaderState state)
 {
     this.ReplaceScope(new AtomScope(state, this.Item, this.CurrentEntityType));
 }
        /// <summary>
        /// Reads from the reader and asserts the reader is in the expected state.
        /// </summary>
        /// <param name="expectedState">The expected state.</param>
        private void ReadAndExpectState(ODataReaderState expectedState)
        {
            this.AssertRead();

            this.ExpectState(expectedState);
        }
            /// <summary>
            /// Constructor creating a new reader scope.
            /// </summary>
            /// <param name="readerState">The reader state of the new scope that is being created.</param>
            /// <param name="entry">The item attached to this scope.</param>
            /// <param name="navigationSource">The navigation source we are going to read entities for.</param>
            /// <param name="expectedEntityType">The expected type for the scope.</param>
            /// <param name="duplicatePropertyNamesChecker">The duplicate property names checker for this entry scope.</param>
            /// <param name="selectedProperties">The selected properties node capturing what properties should be expanded during template evaluation.</param>
            /// <param name="odataUri">The odataUri parsed based on the context uri for current scope</param>
            /// <remarks>The <paramref name="expectedEntityType"/> has the following meaning
            ///   it's the expected base type of the entry. If the entry has no type name specified
            ///   this type will be assumed. Otherwise the specified type name must be
            ///   the expected type or a more derived type.
            /// In all cases the specified type must be an entity type.</remarks>
            internal JsonLightEntryScope(
                ODataReaderState readerState,
                ODataEntry entry,
                IEdmNavigationSource navigationSource,
                IEdmEntityType expectedEntityType,
                DuplicatePropertyNamesChecker duplicatePropertyNamesChecker,
                SelectedPropertiesNode selectedProperties,
                ODataUri odataUri)
                : base(readerState, entry, navigationSource, expectedEntityType, odataUri)
            {
                Debug.Assert(
                    readerState == ODataReaderState.EntryStart || readerState == ODataReaderState.EntryEnd,
                    "readerState == ODataReaderState.EntryStart || readerState == ODataReaderState.EntryEnd");

                this.DuplicatePropertyNamesChecker = duplicatePropertyNamesChecker;
                this.SelectedProperties = selectedProperties;
            }
 /// <summary>
 /// Replaces the current scope with a new scope with the specified <paramref name="state"/> and
 /// the item of the current scope.
 /// </summary>
 /// <param name="state">The <see cref="ODataReaderState"/> to use for the new scope.</param>
 private void ReplaceScope(ODataReaderState state)
 {
     this.ReplaceScope(new Scope(state, this.Item, this.CurrentNavigationSource, this.CurrentEntityType, this.CurrentScope.ODataUri));
 }
Ejemplo n.º 26
0
 internal Scope(ODataReaderState state, ODataItem item, IEdmEntityType expectedEntityType)
 {
     this.state      = state;
     this.item       = item;
     this.EntityType = expectedEntityType;
 }
Ejemplo n.º 27
0
 private void ReplaceScope(ODataReaderState state)
 {
     base.ReplaceScope(new JsonScope(state, this.Item, base.CurrentEntityType));
 }
Ejemplo n.º 28
0
 internal JsonScope(ODataReaderState state, ODataItem item, IEdmEntityType expectedEntityType) : base(state, item, expectedEntityType)
 {
 }
Ejemplo n.º 29
0
 internal Scope(ODataReaderState state, ODataItem item, IEdmNavigationSource navigationSource, IEdmTypeReference expectedResourceTypeReference, ODataUri odataUri)
     : this(state, item, odataUri)
 {
     this.NavigationSource      = navigationSource;
     this.ResourceTypeReference = expectedResourceTypeReference;
 }
Ejemplo n.º 30
0
 internal AtomScope(ODataReaderState state, ODataItem item, IEdmEntityType expectedEntityType) : base(state, item, expectedEntityType)
 {
 }
Ejemplo n.º 31
0
        public override bool Read()
        {
            switch (this.state)
            {
                case ODataReaderState.Start:
                    if (this.currentObject == null)
                    {
                        if (!this.reader.MoveNext())
                        {
                            this.state = ODataReaderState.Exception;
                            return false;
                        }

                        this.currentObject = this.reader.Current;
                    }

                    this.state = readingFeed
                        ? ODataReaderState.FeedStart
                        : ODataReaderState.EntryStart;
                    break;
                case ODataReaderState.FeedStart:
                    this.item = new ODataFeed();
                    var objs = this.currentObject as object[];
                    if (objs == null)
                    {
                        this.state = ODataReaderState.Exception;
                        return false;
                    }

                    this.recordEnumerator = objs.GetEnumerator();

                    this.state = (this.recordEnumerator.MoveNext())
                        ? ODataReaderState.EntryStart
                        : ODataReaderState.FeedEnd;
                    break;
                case ODataReaderState.FeedEnd:
                    this.state = ODataReaderState.Completed;
                    return false;
                case ODataReaderState.EntryStart:
                    var record = (this.readingFeed ? this.recordEnumerator.Current : this.currentObject) as AvroRecord;
                    if (record == null)
                    {
                        this.state = ODataReaderState.Exception;
                        return false;
                    }

                    this.item = ODataAvroConvert.ToODataEntry(record);
                    this.state = ODataReaderState.EntryEnd;
                    return true;
                case ODataReaderState.EntryEnd:
                    if (!readingFeed)
                    {
                        this.state = ODataReaderState.Completed;
                        return false;
                    }

                    this.state = this.recordEnumerator.MoveNext()
                        ? ODataReaderState.EntryStart
                        : ODataReaderState.FeedEnd;
                    break;
                default:
                    throw new ApplicationException("Invalid state");
            }

            return true;
        }
Ejemplo n.º 32
0
 public TestODataReader()
 {
     this.items = new List<TestODataReaderItem>();
     this.currentState = ODataReaderState.Start;
     this.ReadFunc = this.DefaultRead;
 }
Ejemplo n.º 33
0
 private void ExpectState(ODataReaderState expectedState)
 {
     if (this.reader.State != expectedState)
     {
         throw System.Data.Services.Client.Error.InternalError(InternalError.UnexpectedReadState);
     }
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Constructor creating a new reader scope.
 /// </summary>
 /// <param name="state">The reader state of this scope.</param>
 /// <param name="item">The item attached to this scope.</param>
 /// <param name="navigationSource">The navigation source we are going to read entities for.</param>
 /// <param name="expectedResourceType">The expected resource type for the scope.</param>
 /// <param name="odataUri">The odataUri parsed based on the context uri for current scope</param>
 internal StreamScope(ODataReaderState state, ODataItem item, IEdmNavigationSource navigationSource, IEdmTypeReference expectedResourceType, ODataUri odataUri)
     : base(state, item, navigationSource, expectedResourceType, odataUri)
 {
     this.StreamingState = StreamingState.None;
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Creates a new <see cref="AtomScope"/> 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="ODataReaderState"/> to use for the new scope.</param>
 /// <param name="item">The item to attach with the state in the new scope.</param>
 /// <param name="expectedEntityType">The expected type for the new scope.</param>
 private void EnterScope(ODataReaderState state, ODataItem item, IEdmEntityType expectedEntityType)
 {
     this.EnterScope(new AtomScope(state, item, expectedEntityType));
 }
Ejemplo n.º 36
0
        public override bool Read()
        {
            switch (this.state)
            {
            case ODataReaderState.Start:
                if (this.currentObject == null)
                {
                    if (!this.reader.MoveNext())
                    {
                        this.state = ODataReaderState.Exception;
                        return(false);
                    }

                    this.currentObject = this.reader.Current;
                }

                this.state = readingFeed
                        ? ODataReaderState.FeedStart
                        : ODataReaderState.EntryStart;
                break;

            case ODataReaderState.FeedStart:
                this.item = new ODataFeed();
                var objs = this.currentObject as object[];
                if (objs == null)
                {
                    this.state = ODataReaderState.Exception;
                    return(false);
                }

                this.recordEnumerator = objs.GetEnumerator();

                this.state = (this.recordEnumerator.MoveNext())
                        ? ODataReaderState.EntryStart
                        : ODataReaderState.FeedEnd;
                break;

            case ODataReaderState.FeedEnd:
                this.state = ODataReaderState.Completed;
                return(false);

            case ODataReaderState.EntryStart:
                var record = (this.readingFeed ? this.recordEnumerator.Current : this.currentObject) as AvroRecord;
                if (record == null)
                {
                    this.state = ODataReaderState.Exception;
                    return(false);
                }

                this.item  = ODataAvroConvert.ToODataEntry(record);
                this.state = ODataReaderState.EntryEnd;
                return(true);

            case ODataReaderState.EntryEnd:
                if (!readingFeed)
                {
                    this.state = ODataReaderState.Completed;
                    return(false);
                }

                this.state = this.recordEnumerator.MoveNext()
                        ? ODataReaderState.EntryStart
                        : ODataReaderState.FeedEnd;
                break;

            default:
                throw new ApplicationException("Invalid state");
            }

            return(true);
        }
Ejemplo n.º 37
0
        public override bool Read()
        {
            switch (this.state)
            {
            case ODataReaderState.Start:
                if (this.currentObject == null)
                {
                    if (!this.reader.MoveNext())
                    {
                        this.state = ODataReaderState.Exception;
                        return(false);
                    }

                    this.currentObject = this.reader.Current;
                }

                if (readingFeed)
                {
                    this.state = ODataReaderState.ResourceSetStart;
                }
                else
                {
                    this.state = ODataReaderState.ResourceStart;
                    var record = this.currentObject as AvroRecord;

                    return(ReadResourceFromRecord(this.currentObject));
                }
                break;

            case ODataReaderState.ResourceSetStart:
            {
                this.item = new ODataResourceSet();
                scopes.Push(this.item);
                var objs = this.currentObject as object[];
                if (objs == null)
                {
                    this.state = ODataReaderState.Exception;
                    return(false);
                }

                this.recordEnumerator = objs.GetEnumerator();

                return(MoveToNextAndReadResource());
            }

            case ODataReaderState.ResourceSetEnd:
                this.state = ODataReaderState.Completed;
                return(false);

            case ODataReaderState.ResourceStart:
            {
                var nestedInfo = this.scopes.Count > 0 ? this.scopes.Peek() as ODataNestedResourceInfo : null;
                this.scopes.Push(this.item);
                if (nestedInfo != null)
                {
                    this.state = ODataReaderState.ResourceEnd;
                    return(true);
                }

                var record = (this.readingFeed ? this.recordEnumerator.Current : this.currentObject) as AvroRecord;

                nestedInfo = ODataAvroConvert.GetNestedResourceInfo(record);
                if (nestedInfo != null)
                {
                    this.item  = nestedInfo;
                    this.state = ODataReaderState.NestedResourceInfoStart;
                }
                else
                {
                    this.state = ODataReaderState.ResourceEnd;
                }
                return(true);
            }

            case ODataReaderState.ResourceEnd:
            {
                this.scopes.Pop();

                var nestedInfo = this.scopes.Count > 0 ? this.scopes.Peek() as ODataNestedResourceInfo : null;
                if (nestedInfo != null)
                {
                    this.item  = nestedInfo;
                    this.state = ODataReaderState.NestedResourceInfoEnd;
                    return(true);
                }

                if (!readingFeed)
                {
                    this.state = ODataReaderState.Completed;
                    return(false);
                }

                return(MoveToNextAndReadResource());
            }

            case ODataReaderState.NestedResourceInfoStart:
            {
                this.scopes.Push(this.item);
                var record     = (this.readingFeed ? this.recordEnumerator.Current : this.currentObject) as AvroRecord;
                var nestedInfo = this.item as ODataNestedResourceInfo;
                this.item  = ODataAvroConvert.ToODataEntry(record, nestedInfo.Name);
                this.state = ODataReaderState.ResourceStart;
            }
            break;

            case ODataReaderState.NestedResourceInfoEnd:
                this.scopes.Pop();
                this.item  = this.scopes.Peek();
                this.state = ODataReaderState.ResourceEnd;
                break;

            default:
                throw new ApplicationException("Invalid state");
            }

            return(true);
        }
Ejemplo n.º 38
0
 public TestODataReader()
 {
     this.items        = new List <TestODataReaderItem>();
     this.currentState = ODataReaderState.Start;
     this.ReadFunc     = this.DefaultRead;
 }
 private void WriteEnd(ODataWriter writer, ODataReaderState expectedState)
 {
     this.expectedStates.Add(expectedState);
     writer.WriteEnd();
     writer.Flush();
 }
Ejemplo n.º 40
0
 public TestODataReaderItem(ODataReaderState state, ODataItem item)
 {
     this.State = state;
     this.Item  = item;
 }
Ejemplo n.º 41
0
 public TestODataReaderItem(ODataReaderState state, ODataItem item)
 {
     this.State = state;
     this.Item = item;
 }
 /// <summary>
 /// Asserts the reader is in the expected state.
 /// </summary>
 /// <param name="expectedState">The expected state.</param>
 private void ExpectState(ODataReaderState expectedState)
 {
     if (this.reader.State != expectedState)
     {
         throw DSClient.Error.InternalError(InternalError.UnexpectedReadState);
     }
 }
Ejemplo n.º 43
0
 /// <summary>
 /// Constructor creating a new reader scope.
 /// </summary>
 /// <param name="state">The reader state of this scope.</param>
 /// <param name="item">The item attached to this scope.</param>
 /// <param name="expectedEntityType">The expected type for the scope.</param>
 /// <remarks>The <paramref name="expectedEntityType"/> has the following meanings for given state:
 /// Start -               it's the expected base type of the top-level entry or entries in the top-level feed.
 /// FeedStart -           it's the expected base type of the entries in the feed.
 ///                       note that it might be a more derived type than the base type of the entity set for the feed.
 /// EntryStart -          it's the expected base type of the entry. If the entry has no type name specified
 ///                       this type will be assumed. Otherwise the specified type name must be
 ///                       the expected type or a more derived type.
 /// NavigationLinkStart - it's the expected base type the entries in the expanded link (either the single entry
 ///                       or entries in the expanded feed).
 /// In all cases the specified type must be an entity type.</remarks>
 internal AtomScope(ODataReaderState state, ODataItem item, IEdmEntityType expectedEntityType)
     : base(state, item, /*navigationSource*/ null, expectedEntityType, /*contextUri*/null)
 {
 }