public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { string idStr = reader.Value as string; object obj; /* Return the cached object instance instead a new one */ obj = idResolver.ResolveReference(this, idStr); if (obj == null) { obj = DocumentsSerializer.LoadObject(objectType, Guid.Parse(idStr), db, idResolver); idResolver.AddReference(this, idStr, obj); } return(obj); }