private static void RunTheHostFactory(IWindsorContainer container)
{
HostFactory.Run(config =>
{
config.Service<ITopshelfService>(settings =>
{
// use this to instantiate the service
settings.ConstructUsing(hostSettings => container.Resolve<ITopshelfService>());
settings.WhenStarted(service => service.Start());
settings.WhenStopped(service =>
{
service.Stop();
container.Release(service);
container.Dispose();
});
});
config.RunAsLocalSystem();
config.SetDescription("This is an example service.");
config.SetDisplayName("My Example Service");
config.SetServiceName("MyExampleService");
});
}