Esempio n. 1
0
        internal virtual DataServiceQueryContinuation GetContinuation(IEnumerable key)
        {
            Debug.Assert(this.materializer != null, "Materializer is null!");

            DataServiceQueryContinuation result;

            if (key == null)
            {
                if ((this.expectingSingleValue && !this.moved) || (!this.expectingSingleValue && !this.materializer.IsEndOfStream))
                {
                    throw new InvalidOperationException(Strings.MaterializeFromAtom_TopLevelLinkNotAvailable);
                }

                if (this.expectingSingleValue || this.materializer.CurrentFeed == null)
                {
                    result = null;
                }
                else
                {
                    result = DataServiceQueryContinuation.Create(
                        this.materializer.CurrentFeed.NextLink,
                        this.materializer.MaterializeEntryPlan);
                }
            }
            else
            {
                if (!this.materializer.NextLinkTable.TryGetValue(key, out result))
                {
                    throw new ArgumentException(Strings.MaterializeFromAtom_CollectionKeyNotPresentInLinkTable);
                }
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the next link URI for the collection key
        /// </summary>
        /// <param name="key">The collection for which the Uri is returned, or null, if the top level link is to be returned</param>
        /// <returns>An Uri pointing to the next page for the collection</returns>
        internal virtual DataServiceQueryContinuation GetContinuation(IEnumerable key)
        {
            Debug.Assert(this.materializer != null, "Materializer is null!");

            DataServiceQueryContinuation result;

            if (key == null)
            {
                if ((this.expectingPrimitiveValue && !this.moved) || (!this.expectingPrimitiveValue && !this.materializer.IsEndOfStream))
                {
                    // expectingSingleValue && !moved : haven't started parsing single value (single value should not have next link anyway)
                    // !expectingSingleValue && !IsEndOfStream : collection type feed did not finish parsing yet
                    throw new InvalidOperationException(Strings.MaterializeFromAtom_TopLevelLinkNotAvailable);
                }

                // we have already moved to the end of stream
                // are we singleton or just an entry?
                if (this.expectingPrimitiveValue || this.materializer.CurrentFeed == null)
                {
                    result = null;
                }
                else
                {
                    // DEVNOTE(pqian): The next link uri should never be edited by the client, and therefore it must be absolute
                    result = DataServiceQueryContinuation.Create(
                        this.materializer.CurrentFeed.NextPageLink,
                        this.materializer.MaterializeEntryPlan);
                }
            }
            else
            {
                if (!this.materializer.NextLinkTable.TryGetValue(key, out result))
                {
                    // someone has asked for a collection that's "out of scope" or doesn't exist
                    throw new ArgumentException(Strings.MaterializeFromAtom_CollectionKeyNotPresentInLinkTable);
                }
            }

            return(result);
        }
Esempio n. 3
0
        internal virtual DataServiceQueryContinuation GetContinuation(IEnumerable key)
        {
            DataServiceQueryContinuation continuation;

            if (key == null)
            {
                if ((this.expectingPrimitiveValue && !this.moved) || (!this.expectingPrimitiveValue && !this.materializer.IsEndOfStream))
                {
                    throw new InvalidOperationException(System.Data.Services.Client.Strings.MaterializeFromAtom_TopLevelLinkNotAvailable);
                }
                if (this.expectingPrimitiveValue || (this.materializer.CurrentFeed == null))
                {
                    return(null);
                }
                return(DataServiceQueryContinuation.Create(this.materializer.CurrentFeed.NextPageLink, this.materializer.MaterializeEntryPlan));
            }
            if (!this.materializer.NextLinkTable.TryGetValue(key, out continuation))
            {
                throw new ArgumentException(System.Data.Services.Client.Strings.MaterializeFromAtom_CollectionKeyNotPresentInLinkTable);
            }
            return(continuation);
        }