Skip to content

Commit

Permalink
Convenience extension for builing serializers, renaming.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcweber committed Sep 20, 2019
1 parent 7c23ddd commit b9c7c03
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public static IGremlinQueryExecutionPipeline UseSerializer(this IGremlinQueryExe
return pipeline.ConfigureSerializer(_ => serializer);
}

public static IGremlinQueryExecutionPipeline UseSerializer(this IGremlinQueryExecutionPipeline pipeline, Func<IGremlinQuerySerializerBuilder, IGremlinQuerySerializer> builder)
{
return pipeline.ConfigureSerializer(_ => builder(GremlinQuerySerializerBuilder.Invalid));
}

public static IGremlinQueryExecutionPipeline UseDeserializer(this IGremlinQueryExecutionPipeline pipeline, IGremlinQueryExecutionResultDeserializer deserializer)
{
return pipeline.ConfigureDeserializer(_ => deserializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public object Serialize(IGremlinQuery query)

public static readonly IGremlinQuerySerializer Groovy = GremlinQuerySerializerBuilder
.Invalid
.AddGremlinSteps()
.AddGroovy()
.UseDefaultGremlinStepSerializationHandlers()
.UseGroovy()
.Build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public IGremlinQuerySerializer Build()

public static readonly IGremlinQuerySerializerBuilder Invalid = new GremlinQuerySerializerBuilderImpl(ImmutableDictionary<Type, AtomSerializationHandler<object>>.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<HasNotStep>((step, assembler, overridden, recurse) => assembler.Method("hasNot", step.Key, recurse))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SkipStep>((step, assembler, overridden, recurse) => recurse(new RangeStep(step.Count, -1)))
Expand Down

0 comments on commit b9c7c03

Please sign in to comment.