public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var realConverter = serializer.GetStatefulConverter <ConcreteTypeConverter <TDocument> >();

            if (realConverter != null)
            {
                return(ConcreteTypeConverter.GetUsingConcreteTypeConverter <TDocument>(reader, serializer, realConverter));
            }

            var instance = (Hit <TDocument>)(typeof(Hit <TDocument>).CreateInstance());

            serializer.Populate(reader, instance);
            instance.Fields = new FieldValues(serializer.GetConnectionSettings().Inferrer, instance.Fields);
            return(instance);
        }
Пример #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var elasticContractResolver = serializer.ContractResolver as ElasticContractResolver;

            if (elasticContractResolver != null && elasticContractResolver.PiggyBackState != null &&
                elasticContractResolver.PiggyBackState.ActualJsonConverter != null)
            {
                var realConcreteConverter = elasticContractResolver.PiggyBackState.ActualJsonConverter as ConcreteTypeConverter <T>;
                if (realConcreteConverter != null)
                {
                    return(ConcreteTypeConverter.GetUsingConcreteTypeConverter <T>(reader, serializer, realConcreteConverter));
                }
            }

            var instance = (Hit <T>)(typeof(Hit <T>).CreateInstance());

            serializer.Populate(reader, instance);
            instance.Fields = new FieldSelection <T>(elasticContractResolver.ConnectionSettings, instance._fields);
            return(instance);
        }