public void When_Custom_Converter_Configured_In_AppConfig_It_Is_Returned()
        {
            var section = (CouchbaseClientSection)ConfigurationManager.GetSection("couchbaseClients/couchbase_2");
            var config  = new ClientConfiguration(section);

            Assert.IsInstanceOf <FakeConverter>(config.Converter());
        }
 public ClusterController(ClientConfiguration clientConfig)
     : this(clientConfig,
            pool =>
 {
     Log.Debug(m => m("Creating DefaultIOStrategy"));
     return(new DefaultIOStrategy(pool));
 },
            (config, endpoint) =>
 {
     IConnectionPool connectionPool;
     if (config.UseSsl)
     {
         connectionPool = new ConnectionPool <SslConnection>(config, endpoint);
     }
     else
     {
         connectionPool = new ConnectionPool <Connection>(config, endpoint);
     }
     connectionPool.Initialize();
     return(connectionPool);
 },
            SaslFactory.GetFactory3(),
            clientConfig.Converter(),
            clientConfig.Transcoder())
 {
 }
Пример #3
0
 public ClusterController(ClientConfiguration clientConfig)
     : this(clientConfig,
            clientConfig.IOServiceCreator,
            clientConfig.ConnectionPoolCreator,
            clientConfig.CreateSaslMechanism,
            clientConfig.Converter(),
            clientConfig.Transcoder())
 {
 }
        /// <summary>
        /// Gets a Func for creating <see cref="ITypeTranscoder"/> transcoders.
        /// </summary>
        /// <param name="config">The current <see cref="ClientConfiguration"/>.</param>
        /// <param name="typeName">The name of the type implementing <see cref="ITypeTranscoder"/>.</param>
        /// <returns>A <see cref="Func{ITypeTranscoder}"/> for creating <see cref="ITypeTranscoder"/>s.</returns>
        public static Func <ITypeTranscoder> GetTranscoder(ClientConfiguration config, string typeName)
        {
            var parameters = new object[]
            {
                config.Converter(),
                config.Serializer()
            };

            var type = Type.GetType(typeName, true);

            return(() => (ITypeTranscoder)Activator.CreateInstance(type, parameters));
        }
 public ClusterController(ClientConfiguration clientConfig, Func <IConnectionPool, IOStrategy> ioStrategyFactory)
     : this(clientConfig,
            ioStrategyFactory,
            (config, endpoint) =>
 {
     IConnectionPool connectionPool;
     if (config.UseSsl)
     {
         connectionPool = new ConnectionPool <SslConnection>(config, endpoint);
     }
     else
     {
         connectionPool = new ConnectionPool <Connection>(config, endpoint);
     }
     connectionPool.Initialize();
     return(connectionPool);
 }, SaslFactory.GetFactory3(),
            clientConfig.Converter(),
            clientConfig.Transcoder())
 {
 }
 /// <summary>
 /// Gets a Func for creating <see cref="ITypeTranscoder"/> transcoders.
 /// </summary>
 /// <param name="config">The current <see cref="ClientConfiguration"/>.</param>
 /// <returns>A <see cref="Func{ITypeTranscoder}"/> for creating <see cref="ITypeTranscoder"/>s.</returns>
 public static Func <ITypeTranscoder> GetTranscoder(ClientConfiguration config)
 {
     return(() => new DefaultTranscoder(config.Converter(), config.Serializer()));
 }