forked from EasyNetQ/EasyNetQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ComponentRegistration.cs
executable file
·53 lines (46 loc) · 2.44 KB
/
ComponentRegistration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using EasyNetQ.Consumer;
using EasyNetQ.Loggers;
using EasyNetQ.Producer;
namespace EasyNetQ
{
/// <summary>
/// Registers the default EasyNetQ components in our internal super-simple IoC container.
/// </summary>
public class ComponentRegistration
{
public static IServiceProvider CreateServiceProvider(Action<IServiceRegister> registerServices)
{
Preconditions.CheckNotNull(registerServices, "registerServices");
var serviceProvider = new DefaultServiceProvider();
// gives the user a chance to register alternative service implementations.
registerServices(serviceProvider);
// Note: IConnectionConfiguration gets registered when RabbitHutch.CreateBus(..) is run.
// default service registration
serviceProvider
.Register<IEasyNetQLogger, ConsoleLogger>()
.Register<ISerializer, JsonSerializer>()
.Register<IConventions, Conventions>()
.Register<IEventBus, EventBus>()
.Register<ITypeNameSerializer, TypeNameSerializer>()
.Register<Func<string>>(x => CorrelationIdGenerator.GetCorrelationId)
.Register<IClusterHostSelectionStrategy<ConnectionFactoryInfo>, DefaultClusterHostSelectionStrategy<ConnectionFactoryInfo>>()
.Register<IConsumerDispatcherFactory, ConsumerDispatcherFactory>()
.Register<IPublishExchangeDeclareStrategy, PublishExchangeDeclareStrategy>()
.Register<IPublisherConfirms, PublisherConfirms>()
.Register<IConsumerErrorStrategy, DefaultConsumerErrorStrategy>()
.Register<IHandlerRunner, HandlerRunner>()
.Register<IInternalConsumerFactory, InternalConsumerFactory>()
.Register<IConsumerFactory, ConsumerFactory>()
.Register<IConnectionFactory, ConnectionFactoryWrapper>()
.Register<IPersistentChannelFactory, PersistentChannelFactory>()
.Register<IClientCommandDispatcherFactory, ClientCommandDispatcherFactory>()
.Register<IHandlerCollectionFactory, HandlerCollectionFactory>()
.Register<IAdvancedBus, RabbitAdvancedBus>()
.Register<IRpc, Rpc>()
.Register<ISendReceive, SendReceive>()
.Register<IBus, RabbitBus>();
return serviceProvider;
}
}
}