public static InternalSerializer CreateStateful <T>(this IConnectionSettingsValues settings, IJsonFormatter <T> formatter)
        {
            var currentFormatterResolver = ((InternalSerializer)settings.RequestResponseSerializer).FormatterResolver;
            var formatterResolver        = new StatefulFormatterResolver <T>(formatter, currentFormatterResolver);

            return(StatefulSerializerFactory.CreateStateful(settings, formatterResolver));
        }
        public static DefaultHighLevelSerializer CreateStateful <T>(this IElasticsearchSerializer serializer, IJsonFormatter <T> formatter)
        {
            var currentFormatterResolver = ((IInternalSerializerWithFormatter)serializer).FormatterResolver;
            var formatterResolver        = new StatefulFormatterResolver <T>(formatter, currentFormatterResolver);

            return(new DefaultHighLevelSerializer(formatterResolver));
        }
Exemplo n.º 3
0
        public static DefaultHighLevelSerializer CreateStateful <T>(this IElasticsearchSerializer serializer, IJsonFormatter <T> formatter)
        {
            if (!(serializer is IInternalSerializer s) || !s.TryGetJsonFormatter(out var currentFormatterResolver))
            {
                throw new Exception($"Can not create a stateful serializer because {serializer.GetType()} does not yield a json formatter");
            }

            var formatterResolver = new StatefulFormatterResolver <T>(formatter, currentFormatterResolver);

            return(new DefaultHighLevelSerializer(formatterResolver));
        }