Exemplo n.º 1
0
        public void EstablishContext()
        {
            _serviceStarted = new FutureChannel <ServiceRunning>();
            _service        = new TestService();
            _hostChannel    = new TestChannel();

            _coordinator = new Model.ServiceCoordinator();

            var b = new LocalServiceBuilder <TestService>(null, _serviceName, (d, name, coordinator) => _service,
                                                          x => x.Start(), x => x.Stop(), x => { }, x => { });


            _controllerFactory = new ServiceControllerFactory();
            _factory           = _controllerFactory.CreateFactory(inbox => b.Build(inbox, _coordinator));
            _instance          = _factory.GetActor();

            _hostChannel.Connect(x =>
            {
                x.AddChannel(_instance);

                x.AddChannel(_serviceStarted);
            });

            _coordinator.Send(new CreateService(_serviceName));
            _coordinator.Send(new StartService(_serviceName));

            _serviceStarted.WaitUntilCompleted(5.Seconds());
        }
Exemplo n.º 2
0
        public HostBuilder Configure(HostBuilder builder)
        {
            builder.Match <RunBuilder>(x =>
            {
                string name = _name.IsEmpty() ? typeof(TService).Name : _name;

                var serviceBuilder = new LocalServiceBuilder <TService>(x.Description, name, _factory, _start, _stop, _pause, _continue);

                x.AddServiceBuilder(serviceBuilder);
            });

            return(builder);
        }
Exemplo n.º 3
0
        public HostBuilder Configure([NotNull] HostBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }

            builder.Match <RunBuilder>(x =>
            {
                string name = _name.IsEmpty() ? typeof(TService).Name : _name;

                var serviceBuilder = new LocalServiceBuilder <TService>(x.Description, name, _factory, _start, _stop, _pause, _continue);

                x.AddServiceBuilder(serviceBuilder);
            });

            return(builder);
        }