Configuring Topshelf Using A StructureMap Container
January 20, 2010
At Dovetail we use StructureMap a lot. Lately we’ve also been using Topshelf a lot too. This post takes a look at how you can marry these two technologies together. We will be using the StrucutreMap container to configure which services get started by Topshelf at runtime. Simple Services Let’s start simple. We need a way to identify which configured types want to get configured to be spun up by Topshelf. To accomplish this I created an interface called ISimpleService which includes only the Start and Stop methods that Topshelf uses to manage the services lifetime. public interface ISimpleService { void Start(); void Stop(); } Next up we’ll update and expand the example from my previous post Controlling Application Lifetime In Topshelf to have it implement the ISimpleService. We’ll also add another service in charge of spamming the log file. public class LogSpamService :…