Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using System.Linq;
11 : using Cqrs.Azure.ServiceBus;
12 : using Cqrs.Events;
13 : using Ninject.Modules;
14 :
15 : namespace Cqrs.Ninject.Azure.ServiceBus.EventBus.Configuration
16 : {
17 : /// <summary>
18 : /// A <see cref="INinjectModule"/> that wires up <see cref="AzureQueuedEventBusReceiver{TAuthenticationToken}"/> as the <see cref="IEventReceiver"/> and other require components.
19 : /// </summary>
20 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
21 : public class AzureQueuedEventBusReceiverModule<TAuthenticationToken> : AzureEventBusReceiverModule<TAuthenticationToken>
22 1 : {
23 : #region Overrides of AzureEventBusReceiverModule<TAuthenticationToken>
24 :
25 : /// <summary>
26 : /// Loads the module into the kernel.
27 : /// </summary>
28 1 : public override void Load()
29 : {
30 : bool isMessageSerialiserBound = Kernel.GetBindings(typeof(IAzureBusHelper<TAuthenticationToken>)).Any();
31 : if (!isMessageSerialiserBound)
32 : {
33 : Bind<IAzureBusHelper<TAuthenticationToken>>()
34 : .To<AzureBusHelper<TAuthenticationToken>>()
35 : .InSingletonScope();
36 : }
37 :
38 : RegisterEventMessageSerialiser();
39 : var bus = GetOrCreateBus<AzureQueuedEventBusReceiver<TAuthenticationToken>>();
40 :
41 : RegisterEventReceiver(bus);
42 : RegisterEventHandlerRegistrar(bus);
43 : }
44 :
45 : #endregion
46 : }
47 : }
|