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

            return(new PipelineContinuationTokenV1(pipelinedContinuationTokenV0.SourceContinuationToken));
        }
Example #2
0
        public static bool TryParse(
            string rawContinuationToken,
            out PipelineContinuationTokenV0 pipelinedContinuationTokenV0)
        {
            if (rawContinuationToken == null)
            {
                throw new ArgumentNullException(nameof(rawContinuationToken));
            }

            pipelinedContinuationTokenV0 = new PipelineContinuationTokenV0(rawContinuationToken);
            return(true);
        }
Example #3
0
        public static bool TryCreateFromCosmosElement(
            CosmosElement cosmosElement,
            out PipelineContinuationTokenV0 pipelineContinuationTokenV0)
        {
            if (cosmosElement == null)
            {
                throw new ArgumentNullException(nameof(cosmosElement));
            }

            pipelineContinuationTokenV0 = new PipelineContinuationTokenV0(cosmosElement);
            return(true);
        }
Example #4
0
        public static bool TryParse(
            string rawContinuationToken,
            out PipelineContinuationToken pipelineContinuationToken)
        {
            if (rawContinuationToken == null)
            {
                throw new ArgumentNullException(nameof(rawContinuationToken));
            }

            if (!CosmosElement.TryParse <CosmosObject>(
                    rawContinuationToken,
                    out CosmosObject parsedContinuationToken))
            {
                // Failed to parse so we need to assume it's a V0 token
                if (!PipelineContinuationTokenV0.TryParse(
                        rawContinuationToken,
                        out PipelineContinuationTokenV0 pipelineContinuationTokenV0))
                {
                    pipelineContinuationToken = default;
                    return(false);
                }

                pipelineContinuationToken = pipelineContinuationTokenV0;
                return(true);
            }

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

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

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

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

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

            return(true);
        }
Example #5
0
        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);
        }