public static bool TryConvertToLatest( PipelineContinuationToken pipelinedContinuationToken, out PipelineContinuationTokenV1_1 pipelineContinuationTokenV1_1) { if (pipelinedContinuationToken == null) { throw new ArgumentNullException(nameof(pipelinedContinuationToken)); } if (pipelinedContinuationToken is PipelineContinuationTokenV0 pipelineContinuationTokenV0) { pipelinedContinuationToken = new PipelineContinuationTokenV1(pipelineContinuationTokenV0.SourceContinuationToken); } if (pipelinedContinuationToken is PipelineContinuationTokenV1 pipelineContinuationTokenV1) { pipelinedContinuationToken = new PipelineContinuationTokenV1_1( queryPlan: null, sourceContinuationToken: pipelineContinuationTokenV1.SourceContinuationToken); } if (!(pipelinedContinuationToken is PipelineContinuationTokenV1_1 convertedPipelineContinuationTokenV1_1)) { pipelineContinuationTokenV1_1 = default; return(false); }
public static bool TryCreateFromCosmosElement( CosmosObject parsedContinuationToken, out PipelineContinuationTokenV1 pipelinedContinuationTokenV1) { if (parsedContinuationToken == null) { throw new ArgumentNullException(nameof(parsedContinuationToken)); } if (!PipelineContinuationToken.TryParseVersion( parsedContinuationToken, out Version version)) { pipelinedContinuationTokenV1 = default; return(false); } if (version != PipelineContinuationTokenV1.VersionNumber) { pipelinedContinuationTokenV1 = default; return(false); } if (!parsedContinuationToken.TryGetValue( SourceContinuationTokenPropertyName, out CosmosElement sourceContinuationToken)) { pipelinedContinuationTokenV1 = default; return(false); } pipelinedContinuationTokenV1 = new PipelineContinuationTokenV1(sourceContinuationToken); 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); }