public static IGremlinQuerySerializerBuilder UseDefaultGremlinStepSerializationHandlers(this IGremlinQuerySerializerBuilder builder) { return(builder .OverrideAtomSerializer <HasNotStep>((step, assembler, overridden, recurse) => assembler.Method("hasNot", step.Key, recurse)) .OverrideAtomSerializer <ChooseOptionTraversalStep>((step, assembler, overridden, recurse) => assembler.Method("choose", step.Traversal, recurse)) .OverrideAtomSerializer <OptionTraversalStep>((step, assembler, overridden, recurse) => assembler.Method("option", step.Guard, step.OptionTraversal, recurse)) .OverrideAtomSerializer <WithoutStrategiesStep>((step, assembler, overridden, recurse) => { assembler.OpenMethod("withoutStrategies"); foreach (var className in step.ClassNames) { assembler.StartParameter(); assembler.Identifier(className); assembler.EndParameter(); } assembler.CloseMethod(); }) .OverrideAtomSerializer <HasStep>((step, assembler, overridden, recurse) => { if (step.Value is P p1 && p1.EqualsConstant(false)) { recurse(NoneStep.Instance); }
public static IGremlinQuerySerializerBuilder UseCosmosDbWorkarounds(this IGremlinQuerySerializerBuilder builder) { return(builder .OverrideAtomSerializer <SkipStep>((step, assembler, overridden, recurse) => recurse(new RangeStep(step.Count, -1))) .OverrideAtomSerializer <NoneStep>((step, assembler, overridden, recurse) => recurse(NoneWorkaround)) .OverrideAtomSerializer <LimitStep>((step, assembler, overridden, recurse) => { // Workaround for https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/33998623-cosmosdb-s-implementation-of-the-tinkerpop-dsl-has if (step.Count > int.MaxValue) { throw new ArgumentOutOfRangeException(nameof(step), "CosmosDb doesn't currently support values for 'Limit' outside the range of a 32-bit-integer."); } overridden(step); }) .OverrideAtomSerializer <TailStep>((step, assembler, overridden, recurse) => { // Workaround for https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/33998623-cosmosdb-s-implementation-of-the-tinkerpop-dsl-has if (step.Count > int.MaxValue) { throw new ArgumentOutOfRangeException(nameof(step), "CosmosDb doesn't currently support values for 'Tail' outside the range of a 32-bit-integer."); } overridden(step); }) .OverrideAtomSerializer <RangeStep>((step, assembler, overridden, recurse) => { // Workaround for https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/33998623-cosmosdb-s-implementation-of-the-tinkerpop-dsl-has if (step.Lower > int.MaxValue || step.Upper > int.MaxValue) { throw new ArgumentOutOfRangeException(nameof(step), "CosmosDb doesn't currently support values for 'Range' outside the range of a 32-bit-integer."); } overridden(step); }) .OverrideAtomSerializer <long>((l, assembler, overridden, recurse) => { // Workaround for https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/33998623-cosmosdb-s-implementation-of-the-tinkerpop-dsl-has recurse((int)l); })); }