From d9be2ae96677a38c8277f926d2d8de0dba656a45 Mon Sep 17 00:00:00 2001 From: Daniel Weber Date: Fri, 6 Sep 2024 14:01:07 +0200 Subject: [PATCH] Remove PropertyHeuristicConverterFactory. It's uncovered and it's purpose is covered by different converters. --- .../PropertyHeuristicConverterFactory.cs | 48 ------------------- .../GremlinQueryEnvironmentExtensions.cs | 1 - 2 files changed, 49 deletions(-) delete mode 100644 src/Support.NewtonsoftJson/Converters/PropertyHeuristicConverterFactory.cs diff --git a/src/Support.NewtonsoftJson/Converters/PropertyHeuristicConverterFactory.cs b/src/Support.NewtonsoftJson/Converters/PropertyHeuristicConverterFactory.cs deleted file mode 100644 index 07f453503d..0000000000 --- a/src/Support.NewtonsoftJson/Converters/PropertyHeuristicConverterFactory.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Newtonsoft.Json.Linq; -using System.Diagnostics.CodeAnalysis; -using ExRam.Gremlinq.Core.Transformation; -using ExRam.Gremlinq.Core; -using ExRam.Gremlinq.Core.GraphElements; - -namespace ExRam.Gremlinq.Support.NewtonsoftJson -{ - internal sealed class PropertyHeuristicConverterFactory : IConverterFactory - { - private sealed class PropertyHeuristicConverter : IConverter - { - private readonly IGremlinQueryEnvironment _environment; - - public PropertyHeuristicConverter(IGremlinQueryEnvironment environment) - { - _environment = environment; - } - - public bool TryConvert(JObject jObject, ITransformer defer, ITransformer recurse, [NotNullWhen(true)] out TTarget? value) - { - if (jObject.LooksLikeVertexProperty()) - { - if (recurse.TryTransform(jObject, _environment, out VertexProperty? vProp) && vProp is TTarget target) - { - value = target; - return true; - } - } - else if (jObject.LooksLikeProperty()) - { - if (recurse.TryTransform(jObject, _environment, out Property? prop) && prop is TTarget target) - { - value = target; - return true; - } - } - - value = default; - return false; - } - } - - public IConverter? TryCreate(IGremlinQueryEnvironment environment) => typeof(JObject) == typeof(TSource) && typeof(TTarget).IsAssignableFrom(typeof(VertexProperty)) && !typeof(Property).IsAssignableFrom(typeof(TTarget)) - ? (IConverter)(object)new PropertyHeuristicConverter(environment) - : default; - } -} diff --git a/src/Support.NewtonsoftJson/Extensions/GremlinQueryEnvironmentExtensions.cs b/src/Support.NewtonsoftJson/Extensions/GremlinQueryEnvironmentExtensions.cs index 40e6481810..f576a4ce2a 100644 --- a/src/Support.NewtonsoftJson/Extensions/GremlinQueryEnvironmentExtensions.cs +++ b/src/Support.NewtonsoftJson/Extensions/GremlinQueryEnvironmentExtensions.cs @@ -95,7 +95,6 @@ public static IGremlinQueryEnvironment UseNewtonsoftJson(this IGremlinQueryEnvir .Add(new ExtractPropertyValueConverterFactory()) .Add(new ScalarToPropertyConverterFactory()) - .Add(new PropertyHeuristicConverterFactory()) .Add(new VertexOrEdgeConverterFactory()) .Add(new LabelLookupConverterFactory())