Ejemplo n.º 1
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var bulkObj  = reader.ToObject(graphsonObject["bulk"]);
            var valueObj = reader.ToObject(graphsonObject["value"]);

            return(new Traverser(valueObj, bulkObj));
        }
Ejemplo n.º 2
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var id    = reader.ToObject(graphsonObject["id"]);
            var label = (string)graphsonObject["label"] ?? Vertex.DefaultLabel;

            return(new Vertex(id, label));
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="GraphSONMessageSerializer" /> class.
 /// </summary>
 /// <param name="mimeType">The MIME type supported by this serializer.</param>
 /// <param name="graphSONReader">The <see cref="GraphSONReader"/> used to deserialize from GraphSON.</param>
 /// <param name="graphSonWriter">The <see cref="GraphSONWriter"/> used to serialize to GraphSON.</param>
 protected GraphSONMessageSerializer(string mimeType, GraphSONReader graphSONReader,
                                     GraphSONWriter graphSonWriter)
 {
     _mimeType       = mimeType;
     _graphSONReader = graphSONReader;
     _graphSONWriter = graphSonWriter;
 }
Ejemplo n.º 4
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            var bulkObj  = reader.ToObject(graphsonObject.GetProperty("bulk"));
            var valueObj = reader.ToObject(graphsonObject.GetProperty("value"));

            return(new Traverser(valueObj, bulkObj));
        }
Ejemplo n.º 5
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var key     = (string)graphsonObject["key"];
            var value   = reader.ToObject(graphsonObject["value"]);
            var element = graphsonObject["element"] != null?reader.ToObject(graphsonObject["element"]) : null;

            return(new Property(key, value, element));
        }
Ejemplo n.º 6
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            var id    = reader.ToObject(graphsonObject.GetProperty("id"));
            var label = graphsonObject.TryGetProperty("label", out var labelProperty)
                ? labelProperty.GetString()
                : Vertex.DefaultLabel;

            return(new Vertex(id, label));
        }
Ejemplo n.º 7
0
 public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
 {
     if (graphsonObject.ValueKind != JsonValueKind.Array)
     {
         return(new HashSet <object>());
     }
     // ISet<object>
     return(new HashSet <object>(graphsonObject.EnumerateArray().Select(reader.ToObject)));
 }
Ejemplo n.º 8
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            var key     = graphsonObject.GetProperty("key").GetString();
            var value   = reader.ToObject(graphsonObject.GetProperty("value"));
            var element = graphsonObject.TryGetProperty("element", out var elementProperty)
                ? reader.ToObject(elementProperty)
                : null;

            return(new Property(key, value, element));
        }
Ejemplo n.º 9
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var labels =
                graphsonObject["labels"]
                .Select(readObjLabels => new HashSet <string>(readObjLabels.Select(l => (string)l)))
                .ToList <ISet <string> >();
            var objects = graphsonObject["objects"].Select(o => reader.ToObject(o)).ToList();

            return(new Path(labels, objects));
        }
Ejemplo n.º 10
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var id     = reader.ToObject(graphsonObject["id"]);
            var label  = (string)graphsonObject["label"];
            var value  = reader.ToObject(graphsonObject["value"]);
            var vertex = graphsonObject["vertex"] != null
                ? new Vertex(reader.ToObject(graphsonObject["vertex"]))
                : null;

            return(new VertexProperty(id, label, value, vertex));
        }
Ejemplo n.º 11
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var jArray = graphsonObject as JArray;

            if (jArray == null)
            {
                return(new HashSet <object>());
            }
            // ISet<object>
            return(new HashSet <object>(jArray.Select(reader.ToObject)));
        }
Ejemplo n.º 12
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            var id     = reader.ToObject(graphsonObject.GetProperty("id"));
            var label  = graphsonObject.GetProperty("label").GetString();
            var value  = reader.ToObject(graphsonObject.GetProperty("value"));
            var vertex = graphsonObject.TryGetProperty("vertex", out var vertexProperty)
                ? new Vertex(reader.ToObject(vertexProperty))
                : null;

            return(new VertexProperty(id, label, value, vertex));
        }
Ejemplo n.º 13
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            var labels =
                graphsonObject.GetProperty("labels").EnumerateArray()
                .Select(readObjLabels =>
                        new HashSet <string>(readObjLabels.EnumerateArray().Select(l => l.GetString())))
                .ToList <ISet <string> >();
            var objects = graphsonObject.GetProperty("objects").EnumerateArray().Select(o => reader.ToObject(o))
                          .ToList();

            return(new Path(labels, objects));
        }
Ejemplo n.º 14
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            // "labels" is a object[] where each item is ISet<object>
            var labelProperty = (object[])reader.ToObject(graphsonObject.GetProperty("labels"));
            var labels        = labelProperty
                                .Select(x => new HashSet <string>(((ISet <object>)x).Cast <string>()))
                                .ToList <ISet <string> >();

            // "objects" is an object[]
            object[] objects = reader.ToObject(graphsonObject.GetProperty("objects"));
            return(new Path(labels, objects));
        }
Ejemplo n.º 15
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var outVId    = reader.ToObject(graphsonObject["outV"]);
            var outVLabel = (string)(graphsonObject["outVLabel"] ?? Vertex.DefaultLabel);
            var outV      = new Vertex(outVId, outVLabel);
            var inVId     = reader.ToObject(graphsonObject["inV"]);
            var inVLabel  = (string)(graphsonObject["inVLabel"] ?? Vertex.DefaultLabel);
            var inV       = new Vertex(inVId, inVLabel);
            var edgeId    = reader.ToObject(graphsonObject["id"]);
            var edgeLabel = (string)graphsonObject["label"] ?? "edge";

            return(new Edge(edgeId, outV, edgeLabel, inV));
        }
Ejemplo n.º 16
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            if (graphsonObject.ValueKind != JsonValueKind.Array)
            {
                return(EmptyList);
            }
            var result = new object[graphsonObject.GetArrayLength()];

            for (var i = 0; i < result.Length; i++)
            {
                result[i] = reader.ToObject(graphsonObject[i]);
            }
            // object[] implements IList<object>
            return(result);
        }
Ejemplo n.º 17
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            if (graphsonObject.ValueKind != JsonValueKind.Array)
            {
                return(new Dictionary <object, object>(0));
            }
            var result = new Dictionary <object, object>(graphsonObject.GetArrayLength() / 2);

            for (var i = 0; i < graphsonObject.GetArrayLength(); i += 2)
            {
                result[reader.ToObject(graphsonObject[i])] = reader.ToObject(graphsonObject[i + 1]);
            }
            // IDictionary<object, object>
            return(result);
        }
Ejemplo n.º 18
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            if (graphsonObject.ValueKind != JsonValueKind.Array)
            {
                return(new List <object>(0));
            }

            // coerce the BulkSet to List. if the bulk exceeds the int space then we can't coerce to List anyway,
            // so this query will be trouble. we'd need a legit BulkSet implementation here in C#. this current
            // implementation is here to replicate the previous functionality that existed on the server side in
            // previous versions.
            return(Enumerable.Range(0, graphsonObject.GetArrayLength() / 2).SelectMany <int, object>(i =>
                                                                                                     Enumerable.Repeat <object>(reader.ToObject(graphsonObject[i * 2]),
                                                                                                                                (int)reader.ToObject(graphsonObject[i * 2 + 1]))).ToList());
        }
Ejemplo n.º 19
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var jArray = graphsonObject as JArray;

            if (jArray == null)
            {
                return(new Dictionary <object, object>(0));
            }
            var result = new Dictionary <object, object>(jArray.Count / 2);

            for (var i = 0; i < jArray.Count; i += 2)
            {
                result[reader.ToObject(jArray[i])] = reader.ToObject(jArray[i + 1]);
            }
            // IDictionary<object, object>
            return(result);
        }
Ejemplo n.º 20
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var jArray = graphsonObject as JArray;

            if (jArray == null)
            {
                return(EmptyList);
            }
            var result = new object[jArray.Count];

            for (var i = 0; i < result.Length; i++)
            {
                result[i] = reader.ToObject(jArray[i]);
            }
            // object[] implements IList<object>
            return(result);
        }
Ejemplo n.º 21
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var jArray = graphsonObject as JArray;

            if (jArray == null)
            {
                return(new List <object>(0));
            }

            // coerce the BulkSet to List. if the bulk exceeds the int space then we can't coerce to List anyway,
            // so this query will be trouble. we'd need a legit BulkSet implementation here in C#. this current
            // implementation is here to replicate the previous functionality that existed on the server side in
            // previous versions.
            return(Enumerable.Range(0, jArray.Count / 2).SelectMany <int, object>(i =>
                                                                                  Enumerable.Repeat <object>(reader.ToObject(jArray[i * 2]), (int)reader.ToObject(jArray[i * 2 + 1]))).
                   ToList());
        }
Ejemplo n.º 22
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            var outVId    = reader.ToObject(graphsonObject.GetProperty("outV"));
            var outVLabel = graphsonObject.TryGetProperty("outVLabel", out var outVLabelProperty)
                ? outVLabelProperty.GetString()
                : Vertex.DefaultLabel;
            var outV     = new Vertex(outVId, outVLabel);
            var inVId    = reader.ToObject(graphsonObject.GetProperty("inV"));
            var inVLabel = graphsonObject.TryGetProperty("inVLabel", out var inVLabelProperty)
                ? inVLabelProperty.GetString()
                : Vertex.DefaultLabel;
            var inV       = new Vertex(inVId, inVLabel);
            var edgeId    = reader.ToObject(graphsonObject.GetProperty("id"));
            var edgeLabel = graphsonObject.TryGetProperty("label", out var labelProperty)
                ? labelProperty.GetString()
                : "edge";

            return(new Edge(edgeId, outV, edgeLabel, inV));
        }
Ejemplo n.º 23
0
 public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
 {
     return(FromJsonElement(graphsonObject));
 }
Ejemplo n.º 24
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            var base64String = graphsonObject.GetString();

            return(Convert.FromBase64String(base64String));
        }
Ejemplo n.º 25
0
        public dynamic Objectify(JsonElement graphson, GraphSONReader reader)
        {
            var bigInteger = graphson.ValueKind == JsonValueKind.String ? graphson.GetString() : graphson.GetRawText();

            return(BigInteger.Parse(bigInteger));
        }
Ejemplo n.º 26
0
 public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
 {
     return(graphsonObject.ToObject <Guid>());
 }
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var bigInteger = graphsonObject.ToObject <string>();

            return(BigInteger.Parse(bigInteger));
        }
Ejemplo n.º 28
0
 public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
 {
     return(graphsonObject.ToObject(HandledType));
 }
Ejemplo n.º 29
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var duration = graphsonObject.ToObject <string>();

            return(XmlConvert.ToTimeSpan(duration));
        }
Ejemplo n.º 30
0
 public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
 {
     return(T.GetByValue(graphsonObject.ToString()));
 }