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 cdmdotnet.Logging;
11 : using Cqrs.Configuration;
12 :
13 : namespace Cqrs.Hosts
14 : {
15 : /// <summary>
16 : /// A startUp action for the <see cref="CoreHost{TAuthenticationToken}"/>
17 : /// </summary>
18 : public class StartUp
19 1 : {
20 : /// <summary>
21 : /// The <see cref="Action"/> that will configure the <see cref="DependencyResolver"/>.
22 : /// </summary>
23 : protected Action DependencyResolverConfigurationFunction { get; set; }
24 :
25 : /// <summary>
26 : /// Instantiate a new instance of a <see cref="StartUp"/>
27 : /// </summary>
28 1 : public StartUp(Action dependencyResolverConfigurationFunction)
29 : {
30 : DependencyResolverConfigurationFunction = dependencyResolverConfigurationFunction;
31 : }
32 :
33 : /// <summary>
34 : /// Initialise by calling the <see cref="DependencyResolverConfigurationFunction"/>.
35 : /// </summary>
36 1 : public virtual void Initialise()
37 : {
38 : DependencyResolverConfigurationFunction();
39 :
40 : var correlationIdHelper = DependencyResolver.Current.Resolve<ICorrelationIdHelper>();
41 : correlationIdHelper.SetCorrelationId(Guid.NewGuid());
42 :
43 : var logger = DependencyResolver.Current.Resolve<ILogger>();
44 :
45 : logger.LogInfo("Application Initialised.");
46 : }
47 : }
48 : }
|