/// <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 void When_Custom_Serializer_Configured_In_AppConfig_It_Is_Returned() { var section = (CouchbaseClientSection)ConfigurationManager.GetSection("couchbaseClients/couchbase_2"); var config = new ClientConfiguration(section); Assert.IsInstanceOf<FakeSerializer>(config.Serializer()); }
/// <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()); }