public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var response = new MultiGetResponse(); var jsonObject = JObject.Load(reader); var docsJarray = (JArray)jsonObject["docs"]; var multiGetDescriptor = this._descriptor; if (this._descriptor == null) { return(multiGetDescriptor); } var withMeta = docsJarray.Zip(this._descriptor._GetOperations, (doc, desc) => new MultiHitTuple { Hit = doc, Descriptor = desc }); foreach (var m in withMeta) { var generic = MakeDelegateMethodInfo.MakeGenericMethod(m.Descriptor._ClrType); generic.Invoke(null, new object[] { m, serializer, response._Documents }); } return(response); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (this._descriptor == null) { var elasticContractResolver = serializer.ContractResolver as ElasticContractResolver; if (elasticContractResolver == null) { return new MultiGetResponse { IsValid = false } } ; var piggyBackState = elasticContractResolver.PiggyBackState; if (piggyBackState == null || piggyBackState.ActualJsonConverter == null) { return new MultiGetResponse { IsValid = false } } ; var realConverter = piggyBackState.ActualJsonConverter as MultiGetHitConverter; if (realConverter == null) { return new MultiGetResponse { IsValid = false } } ; return(realConverter.ReadJson(reader, objectType, existingValue, serializer)); } var response = new MultiGetResponse(); var jsonObject = JObject.Load(reader); var docsJarray = (JArray)jsonObject["docs"]; var multiGetDescriptor = this._descriptor; if (this._descriptor == null) { return(multiGetDescriptor); } var withMeta = docsJarray.Zip(this._descriptor._GetOperations, (doc, desc) => new MultiHitTuple { Hit = doc, Descriptor = desc }); foreach (var m in withMeta) { var generic = MakeDelegateMethodInfo.MakeGenericMethod(m.Descriptor._ClrType); generic.Invoke(null, new object[] { m, serializer, response._Documents }); } return(response); }