Esempio 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));
        }
        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;
 }
Esempio 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));
        }
        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));
        }
Esempio 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));
        }
Esempio 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)));
 }
Esempio 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));
        }
Esempio 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));
        }
Esempio 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));
        }
Esempio 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)));
        }
Esempio 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));
        }
Esempio 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));
        }
Esempio 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));
        }
Esempio 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));
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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());
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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());
        }
Esempio 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));
        }
Esempio n. 23
0
 public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
 {
     return(FromJsonElement(graphsonObject));
 }
Esempio n. 24
0
        public dynamic Objectify(JsonElement graphsonObject, GraphSONReader reader)
        {
            var base64String = graphsonObject.GetString();

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

            return(BigInteger.Parse(bigInteger));
        }
Esempio 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));
        }
Esempio n. 28
0
 public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
 {
     return(graphsonObject.ToObject(HandledType));
 }
Esempio n. 29
0
        public dynamic Objectify(JToken graphsonObject, GraphSONReader reader)
        {
            var duration = graphsonObject.ToObject <string>();

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