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.Commands;
13 : using Ninject.Modules;
14 :
15 : namespace Cqrs.Ninject.Azure.ServiceBus.CommandBus.Configuration
16 : {
17 : /// <summary>
18 : /// A <see cref="INinjectModule"/> that wires up <see cref="AzureQueuedCommandBusReceiver{TAuthenticationToken}"/> as the <see cref="ICommandReceiver"/> and other require components.
19 : /// </summary>
20 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
21 : public class AzureQueuedCommandBusReceiverModule<TAuthenticationToken> : AzureCommandBusReceiverModule<TAuthenticationToken>
22 1 : {
23 : /// <summary>
24 : /// Loads the module into the kernel.
25 : /// </summary>
26 1 : public override void Load()
27 : {
28 : bool isMessageSerialiserBound = Kernel.GetBindings(typeof(IAzureBusHelper<TAuthenticationToken>)).Any();
29 : if (!isMessageSerialiserBound)
30 : {
31 : Bind<IAzureBusHelper<TAuthenticationToken>>()
32 : .To<AzureBusHelper<TAuthenticationToken>>()
33 : .InSingletonScope();
34 : }
35 :
36 : var bus = GetOrCreateBus<AzureQueuedCommandBusReceiver<TAuthenticationToken>>();
37 :
38 : RegisterCommandReceiver(bus);
39 : RegisterCommandHandlerRegistrar(bus);
40 : RegisterCommandMessageSerialiser();
41 : }
42 : }
43 : }
|