public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { // Read the type of the object and create a new instance. // Invoke a helper to populate the common fields for the entity // Parse the rest var json = JObject.ReadFrom(reader) as JObject; if (json == null || json.Type == JTokenType.Null) { return(null); } var conn = BuildNewInstance(json, objectType); EntityParser.ReadJson(conn, json, serializer); // The only field only available in connection ie, endpoints ParseEndpoints(conn, json, serializer); return(conn); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { // Read the type of the object and create a new instance. // Invoke a helper to populate the common fields for the entity // Parse the rest var json = JObject.ReadFrom(reader) as JObject; if (json == null || json.Type == JTokenType.Null) { return(null); } var instance = BuildNewInstance(json, objectType); EntityParser.ReadJson(instance, json, serializer); // The only field only available in ap object is acl. AclParser.ReadAcl(instance, json, serializer); // Read any type specific fields if (instance is APUser) { UserParser.ReadJson(instance as APUser, json); } return(instance); }