/// <summary> /// Registers a middleware to compress the message /// </summary> /// <param name="middlewares"></param> /// <param name="factory">A factory to create the <see cref="IMessageCompressor"/> instance</param> public static IProducerMiddlewareConfigurationBuilder AddCompressor <T>( this IProducerMiddlewareConfigurationBuilder middlewares, Factory <T> factory) where T : class, IMessageCompressor { return(middlewares.Add(resolver => new CompressorProducerMiddleware(factory(resolver)))); }
/// <summary> /// Register a middleware to compress the message /// </summary> /// <typeparam name="T">A class that implements <see cref="IMessageCompressor"/></typeparam> /// <param name="middlewares"></param> /// <param name="factory">A factory to create the <see cref="IMessageCompressor"/> instance</param> public static IProducerMiddlewareConfigurationBuilder AddCompressor <T>( this IProducerMiddlewareConfigurationBuilder middlewares, Factory <T> factory) where T : class, IMessageCompressor { middlewares.DependencyConfigurator.AddSingleton <IMessageCompressor, T>(); middlewares.DependencyConfigurator.AddSingleton <T>(); return(middlewares.Add( provider => new CompressorProducerMiddleware(factory(provider)))); }
/// <summary> /// Registers a middleware to serialize messages /// </summary> /// <typeparam name="TSerializer">A class that implements <see cref="IMessageSerializer"/></typeparam>x public static IProducerMiddlewareConfigurationBuilder AddSerializer <TSerializer>( this IProducerMiddlewareConfigurationBuilder middlewares) where TSerializer : class, IMessageSerializer { middlewares.DependencyConfigurator.AddTransient <TSerializer>(); return(middlewares.Add( resolver => new SerializerProducerMiddleware( resolver.Resolve <TSerializer>(), new DefaultMessageTypeResolver()))); }
/// <summary> /// Registers a middleware to serialize messages /// </summary> /// <typeparam name="TSerializer">A class that implements <see cref="IMessageSerializer"/></typeparam> /// <typeparam name="TResolver">A class that implements <see cref="IMessageTypeResolver"/></typeparam> /// <param name="middlewares"></param> /// <param name="serializerFactory">A factory to create a <see cref="IMessageSerializer"/></param> /// <param name="resolverFactory">A factory to create a <see cref="IMessageTypeResolver"/></param> public static IProducerMiddlewareConfigurationBuilder AddSerializer <TSerializer, TResolver>( this IProducerMiddlewareConfigurationBuilder middlewares, Factory <TSerializer> serializerFactory, Factory <TResolver> resolverFactory) where TSerializer : class, IMessageSerializer where TResolver : class, IMessageTypeResolver { return(middlewares.Add( resolver => new SerializerProducerMiddleware( serializerFactory(resolver), resolverFactory(resolver)))); }
/// <summary> /// Registers a middleware to serialize messages /// </summary> /// <typeparam name="TSerializer">A class that implements <see cref="IMessageSerializer"/></typeparam> /// <typeparam name="TResolver">A class that implements <see cref="IMessageTypeResolver"/></typeparam> /// <param name="producer"></param> /// <param name="serializerFactory">A factory to create a <see cref="IMessageSerializer"/></param> /// <param name="resolverFactory">A factory to create a <see cref="IMessageTypeResolver"/></param> public static IProducerMiddlewareConfigurationBuilder AddSerializer <TSerializer, TResolver>( this IProducerMiddlewareConfigurationBuilder producer, Factory <TSerializer> serializerFactory, Factory <TResolver> resolverFactory) where TSerializer : class, IMessageSerializer where TResolver : class, IMessageTypeResolver { producer.DependencyConfigurator.AddSingleton <IMessageSerializer, TSerializer>(); producer.DependencyConfigurator.AddSingleton <IMessageTypeResolver, TResolver>(); producer.DependencyConfigurator.AddSingleton <TSerializer>(); producer.DependencyConfigurator.AddSingleton <TResolver>(); return(producer.Add( provider => new SerializerProducerMiddleware( serializerFactory(provider), resolverFactory(provider)))); }