// ReSharper disable UnusedMember.Local void InitializeAndCreateHostedService <T>(Bootstrapper <T> bootstrapper) // ReSharper restore UnusedMember.Local where T : class { _log.DebugFormat("[{0}] Creating service type: {1}", _serviceName, typeof(T).ToShortTypeName()); _fiber = new PoolFiber(); _channel = HostChannelFactory.CreateShelfHost(_serviceName, AddEventForwarders); _controllerChannel.Send(new ShelfCreated(_serviceName, _channel.Address, _channel.PipeName)); _host = HostFactory.New(x => { x.SetServiceName(_serviceName); x.UseBuilder(description => new ShelfBuilder(description, _channel)); x.Service <T>(s => { var serviceConfigurator = new ServiceConfiguratorImpl <T>(s); bootstrapper.InitializeHostedService(serviceConfigurator); s.SetServiceName(_serviceName); }); }); _host.Run(); }
public void Send <T>(T message) { if (_channel == null) { _log.WarnFormat("Unable to send service message due to null channel, service = {0}, message type = {1}", _serviceName, typeof(T).ToShortTypeName()); return; } _channel.Send(message); }