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 InternalSerializer CreateStateful(this IConnectionSettingsValues settings, JsonConverter converter)
        {
            var s = (settings as ConnectionSettings)
                    ?? throw new NullReferenceException($"Stateful serializer expected {nameof(IConnectionSettingsValues)} to be {nameof(ConnectionSettings)}");

            return(StatefulSerializerFactory.CreateStateful(s, converter));
        }
        protected ConnectionSettingsBase(
            IConnectionPool connectionPool,
            IConnection connection,
            ConnectionSettings.SourceSerializerFactory sourceSerializerFactory,
            IPropertyMappingProvider propertyMappingProvider
            )
            : base(connectionPool, connection, null)
        {
            var defaultSerializer = new JsonNetSerializer(this);

            this._sourceSerializer = sourceSerializerFactory?.Invoke(defaultSerializer, this) ?? defaultSerializer;
            this.UseThisRequestResponseSerializer = defaultSerializer;
            this._propertyMappingProvider         = propertyMappingProvider ?? new PropertyMappingProvider();

            this._defaultTypeNameInferrer  = (t => t.Name.ToLowerInvariant());
            this._defaultFieldNameInferrer = (p => p.ToCamelCase());
            this._defaultIndices           = new FluentDictionary <Type, string>();
            this._defaultTypeNames         = new FluentDictionary <Type, string>();
            this._defaultRelationNames     = new FluentDictionary <Type, string>();

            this.SerializerFactory = new StatefulSerializerFactory();

            this._inferrer = new Inferrer(this);
        }