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));
        }