From b9c7c0383561b8c3ce9497e0d15736e0335d3d47 Mon Sep 17 00:00:00 2001 From: "Daniel C. Weber" Date: Fri, 20 Sep 2019 14:06:15 +0200 Subject: [PATCH] Convenience extension for builing serializers, renaming. --- .../ExecutionPipelines/GremlinQueryExecutionPipeline.cs | 5 +++++ .../ExecutionPipelines/GremlinQuerySerializer.cs | 4 ++-- .../GremlinQuerySerializerBuilder.cs | 4 ++-- .../GremlinQueryExecutionPipelinesExtensions.cs | 8 ++++---- .../GremlinQuerySerializerBuilderExtensions.cs | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ExRam.Gremlinq.Core/ExecutionPipelines/GremlinQueryExecutionPipeline.cs b/ExRam.Gremlinq.Core/ExecutionPipelines/GremlinQueryExecutionPipeline.cs index 54b563debf..f33c010846 100644 --- a/ExRam.Gremlinq.Core/ExecutionPipelines/GremlinQueryExecutionPipeline.cs +++ b/ExRam.Gremlinq.Core/ExecutionPipelines/GremlinQueryExecutionPipeline.cs @@ -67,6 +67,11 @@ public static IGremlinQueryExecutionPipeline UseSerializer(this IGremlinQueryExe return pipeline.ConfigureSerializer(_ => serializer); } + public static IGremlinQueryExecutionPipeline UseSerializer(this IGremlinQueryExecutionPipeline pipeline, Func builder) + { + return pipeline.ConfigureSerializer(_ => builder(GremlinQuerySerializerBuilder.Invalid)); + } + public static IGremlinQueryExecutionPipeline UseDeserializer(this IGremlinQueryExecutionPipeline pipeline, IGremlinQueryExecutionResultDeserializer deserializer) { return pipeline.ConfigureDeserializer(_ => deserializer); diff --git a/ExRam.Gremlinq.Core/ExecutionPipelines/GremlinQuerySerializer.cs b/ExRam.Gremlinq.Core/ExecutionPipelines/GremlinQuerySerializer.cs index 6886986cc4..59f4210b8c 100644 --- a/ExRam.Gremlinq.Core/ExecutionPipelines/GremlinQuerySerializer.cs +++ b/ExRam.Gremlinq.Core/ExecutionPipelines/GremlinQuerySerializer.cs @@ -28,8 +28,8 @@ public object Serialize(IGremlinQuery query) public static readonly IGremlinQuerySerializer Groovy = GremlinQuerySerializerBuilder .Invalid - .AddGremlinSteps() - .AddGroovy() + .UseDefaultGremlinStepSerializationHandlers() + .UseGroovy() .Build(); } } diff --git a/ExRam.Gremlinq.Core/ExecutionPipelines/SerializedQueryAssembly/GremlinQuerySerializerBuilder.cs b/ExRam.Gremlinq.Core/ExecutionPipelines/SerializedQueryAssembly/GremlinQuerySerializerBuilder.cs index ed4493525b..e6128e0d9d 100644 --- a/ExRam.Gremlinq.Core/ExecutionPipelines/SerializedQueryAssembly/GremlinQuerySerializerBuilder.cs +++ b/ExRam.Gremlinq.Core/ExecutionPipelines/SerializedQueryAssembly/GremlinQuerySerializerBuilder.cs @@ -94,13 +94,13 @@ public IGremlinQuerySerializer Build() public static readonly IGremlinQuerySerializerBuilder Invalid = new GremlinQuerySerializerBuilderImpl(ImmutableDictionary>.Empty, SerializedGremlinQueryAssemblerFactory.Invalid); - public static IGremlinQuerySerializerBuilder AddGroovy(this IGremlinQuerySerializerBuilder builder) + public static IGremlinQuerySerializerBuilder UseGroovy(this IGremlinQuerySerializerBuilder builder) { return builder .ConfigureAssemblerFactory(_ => SerializedGremlinQueryAssemblerFactory.Groovy); } - public static IGremlinQuerySerializerBuilder AddGremlinSteps(this IGremlinQuerySerializerBuilder builder) + public static IGremlinQuerySerializerBuilder UseDefaultGremlinStepSerializationHandlers(this IGremlinQuerySerializerBuilder builder) { return builder .OverrideAtomSerializationHandler((step, assembler, overridden, recurse) => assembler.Method("hasNot", step.Key, recurse)) diff --git a/ExRam.Gremlinq.Providers.CosmosDb/GremlinQueryExecutionPipelinesExtensions.cs b/ExRam.Gremlinq.Providers.CosmosDb/GremlinQueryExecutionPipelinesExtensions.cs index f631938fef..a278a5815d 100644 --- a/ExRam.Gremlinq.Providers.CosmosDb/GremlinQueryExecutionPipelinesExtensions.cs +++ b/ExRam.Gremlinq.Providers.CosmosDb/GremlinQueryExecutionPipelinesExtensions.cs @@ -57,10 +57,10 @@ public static IGremlinQueryExecutionPipeline UseCosmosDbDeserializer(this IGreml public static IGremlinQueryExecutionPipeline UseCosmosDbSerializer(this IGremlinQueryExecutionPipeline pipeline) { return pipeline - .UseSerializer(GremlinQuerySerializerBuilder.Invalid - .AddGremlinSteps() - .AddGroovy() - .AddCosmosDbWorkarounds() + .UseSerializer(builder => builder + .UseDefaultGremlinStepSerializationHandlers() + .UseGroovy() + .UseCosmosDbWorkarounds() .Build()); } diff --git a/ExRam.Gremlinq.Providers.CosmosDb/GremlinQuerySerializerBuilderExtensions.cs b/ExRam.Gremlinq.Providers.CosmosDb/GremlinQuerySerializerBuilderExtensions.cs index 0faa3470e0..a2be32526c 100644 --- a/ExRam.Gremlinq.Providers.CosmosDb/GremlinQuerySerializerBuilderExtensions.cs +++ b/ExRam.Gremlinq.Providers.CosmosDb/GremlinQuerySerializerBuilderExtensions.cs @@ -6,7 +6,7 @@ public static class GremlinQuerySerializerBuilderExtensions { private static readonly Step NoneWorkaround = new NotStep(GremlinQuery.Anonymous(GremlinQueryEnvironment.Default).Identity()); - public static IGremlinQuerySerializerBuilder AddCosmosDbWorkarounds(this IGremlinQuerySerializerBuilder builder) + public static IGremlinQuerySerializerBuilder UseCosmosDbWorkarounds(this IGremlinQuerySerializerBuilder builder) { return builder .OverrideAtomSerializationHandler((step, assembler, overridden, recurse) => recurse(new RangeStep(step.Count, -1)))