Beispiel #1
0
            public override object ReadJson(JsonReader reader, Type objectType, [AllowNull] object existingValue, JsonSerializer serializer)
            {
                var jToken = JToken.Load(reader);

                if (jToken is JObject)
                {
                    var label = jToken["label"]?.ToString();

                    var modelType = label != null
                        ? _model
                                    .GetTypes(label)
                                    .FirstOrDefault(type => objectType.IsAssignableFrom(type))
                        : null;

                    if (modelType != null)
                    {
                        objectType = modelType;
                    }
                    else
                    {
                        if (objectType == typeof(IVertex))
                        {
                            objectType = typeof(VertexImpl);
                        }
                        else if (objectType == typeof(IEdge))
                        {
                            objectType = typeof(EdgeImpl);
                        }
                    }
                }

                using (Block())
                {
                    return(jToken.ToObject(objectType, serializer));
                }
            }
Beispiel #2
0
 public override Type[] GetTypes(string label) => _baseGraphModel.GetTypes(label);
Beispiel #3
0
 public override Type[] GetTypes(string label) => _model.GetTypes(label);