TINKERPOP-1854 Add lambda properties to ILambda interface
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/820adc44 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/820adc44 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/820adc44 Branch: refs/heads/TINKERPOP-1920 Commit: 820adc44f3e2c3359f9f345f554d2b936642e7f0 Parents: 7fbb779 Author: Florian Hockmann <f...@florian-hockmann.de> Authored: Fri Mar 16 18:52:49 2018 +0100 Committer: Florian Hockmann <f...@florian-hockmann.de> Committed: Fri Mar 16 18:52:49 2018 +0100 ---------------------------------------------------------------------- .../src/Gremlin.Net/Process/Traversal/Lambda.cs | 14 +++++++ .../Structure/IO/GraphSON/GraphSONWriter.cs | 2 +- .../Structure/IO/GraphSON/LambdaSerializer.cs | 43 ++++++++++++++++++++ .../IO/GraphSON/StringBasedLambdaSerializer.cs | 43 -------------------- 4 files changed, 58 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs index 12eb016..c1a0e44 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Process/Traversal/Lambda.cs @@ -29,6 +29,20 @@ namespace Gremlin.Net.Process.Traversal public interface ILambda : IFunction, IBiFunction, IPredicate, IUnaryOperator, IBinaryOperator, IComparator, IConsumer, ISupplier { + /// <summary> + /// Gets the lambda expression. + /// </summary> + string LambdaExpression { get; } + + /// <summary> + /// Gets the language of this lambda. + /// </summary> + string Language { get; } + + /// <summary> + /// Gets the arguments of this lambda. + /// </summary> + object Arguments { get; } } /// <summary> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs index 0ef2bde..7185868 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs @@ -60,7 +60,7 @@ namespace Gremlin.Net.Structure.IO.GraphSON {typeof(Property), new PropertySerializer()}, {typeof(VertexProperty), new VertexPropertySerializer()}, {typeof(AbstractTraversalStrategy), new TraversalStrategySerializer()}, - {typeof(ILambda), new StringBasedLambdaSerializer()} + {typeof(ILambda), new LambdaSerializer()} }; /// <summary> http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs new file mode 100644 index 0000000..45e4632 --- /dev/null +++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/LambdaSerializer.cs @@ -0,0 +1,43 @@ +#region License + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#endregion + +using System.Collections.Generic; +using Gremlin.Net.Process.Traversal; + +namespace Gremlin.Net.Structure.IO.GraphSON +{ + internal class LambdaSerializer : IGraphSONSerializer + { + public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer) + { + ILambda lambda = objectData; + var valueDict = new Dictionary<string, dynamic> + { + {"script", lambda.LambdaExpression}, + {"language", lambda.Language}, + {"arguments", lambda.Arguments} + }; + return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/820adc44/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs ---------------------------------------------------------------------- diff --git a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs deleted file mode 100644 index 2e66367..0000000 --- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/StringBasedLambdaSerializer.cs +++ /dev/null @@ -1,43 +0,0 @@ -#region License - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#endregion - -using System.Collections.Generic; -using Gremlin.Net.Process.Traversal; - -namespace Gremlin.Net.Structure.IO.GraphSON -{ - internal class StringBasedLambdaSerializer : IGraphSONSerializer - { - public Dictionary<string, dynamic> Dictify(dynamic objectData, GraphSONWriter writer) - { - StringBasedLambda lambda = objectData; - var valueDict = new Dictionary<string, dynamic> - { - {"script", lambda.LambdaExpression}, - {"language", lambda.Language}, - {"arguments", lambda.Arguments} - }; - return GraphSONUtil.ToTypedValue(nameof(Lambda), valueDict); - } - } -} \ No newline at end of file