Exemplo n.º 1
0
        public ServiceInitiator(IEnumerable <IConfigurationAgent> agents, IModule[] modules)
        {
            _logger = LogManager.GetLogger(typeof(ServiceInitiator));
            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json")
                         .Build();

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterInstance(config).As <IConfiguration>();

            containerBuilder.RegisterConsumers(Assembly.GetExecutingAssembly());

            foreach (var module in modules)
            {
                containerBuilder.RegisterModule(module);
            }

            var configurator = agents.Aggregate(new TransportConfigurator(containerBuilder, config),
                                                (c, a) => c.WithAgent(a));

            _configuredTransport = configurator.Configure();

            _configuredTransport.Start();

            _logger.Info("Started the transport");
        }
Exemplo n.º 2
0
 public void OnStart(IConfiguredTransport transport)
 {
     transport.BuiltContainer.Resolve <IBusControl>().Start();
 }
Exemplo n.º 3
0
 public void OnRelease(IConfiguredTransport transport)
 {
     transport.BuiltContainer.Resolve <IBusControl>().Stop();
 }