Esempio n. 1
0
        public static PipelineContinuationTokenV1 CreateFromV0Token(
            PipelineContinuationTokenV0 pipelinedContinuationTokenV0)
        {
            if (pipelinedContinuationTokenV0 == null)
            {
                throw new ArgumentNullException(nameof(pipelinedContinuationTokenV0));
            }

            return(new PipelineContinuationTokenV1(pipelinedContinuationTokenV0.SourceContinuationToken));
        }
Esempio n. 2
0
        public static bool TryCreateFromCosmosElement(
            CosmosElement cosmosElement,
            out PipelineContinuationTokenV0 pipelineContinuationTokenV0)
        {
            if (cosmosElement == null)
            {
                throw new ArgumentNullException(nameof(cosmosElement));
            }

            pipelineContinuationTokenV0 = new PipelineContinuationTokenV0(cosmosElement);
            return(true);
        }
        public static bool TryCreateFromCosmosElement(
            CosmosElement cosmosElement,
            out PipelineContinuationToken pipelineContinuationToken)
        {
            if (cosmosElement == null)
            {
                throw new ArgumentNullException(nameof(cosmosElement));
            }

            if (!(cosmosElement is CosmosObject cosmosObject))
            {
                // Not a CosmosObject, so it doesn't have a version number, so
                pipelineContinuationToken = new PipelineContinuationTokenV0(cosmosElement);
                return(true);
            }

            if (!PipelineContinuationToken.TryParseVersion(
                    cosmosObject,
                    out Version version))
            {
                pipelineContinuationToken = default;
                return(false);
            }

            if (version == PipelineContinuationTokenV0.VersionNumber)
            {
                if (!PipelineContinuationTokenV0.TryCreateFromCosmosElement(
                        cosmosElement,
                        out PipelineContinuationTokenV0 pipelineContinuationTokenV0))
                {
                    pipelineContinuationToken = default;
                    return(false);
                }

                pipelineContinuationToken = pipelineContinuationTokenV0;
            }
            else if (version == PipelineContinuationTokenV1.VersionNumber)
            {
                if (!PipelineContinuationTokenV1.TryCreateFromCosmosElement(
                        cosmosObject,
                        out PipelineContinuationTokenV1 pipelineContinuationTokenV1))
                {
                    pipelineContinuationToken = default;
                    return(false);
                }

                pipelineContinuationToken = pipelineContinuationTokenV1;
            }
            else if (version == PipelineContinuationTokenV1_1.VersionNumber)
            {
                if (!PipelineContinuationTokenV1_1.TryCreateFromCosmosElement(
                        cosmosObject,
                        out PipelineContinuationTokenV1_1 pipelineContinuationTokenV1_1))
                {
                    pipelineContinuationToken = default;
                    return(false);
                }

                pipelineContinuationToken = pipelineContinuationTokenV1_1;
            }
            else
            {
                pipelineContinuationToken = default;
                return(false);
            }

            return(true);
        }