logo

Topshelf.LightCore

Topshelf.LightCore is a binding to use LightCore as DI container when using Topshelf.

Open-Source

Topshelf.LightCore is free to use, improve, contribute and distribute. Source code is available on GitHub under MIT license.

How to use it?

Topshelf.LightCore supplies Topshelf with extensions to resolve services using LightCore.

Simply start out by configuring the LightCore-container as usual, then use the UseLightCore-extension when setting up the HostFactory. To constuct a service use the ConstructUsingLightCore-extension.

Example:


// setup LightCore
var builder = new ContainerBuilder();
/* some fancy setup here */
var container = builder.Build();

// setup Topshelf
var host = HostFactory.Run(x =>
{
    x.UseLightCore(container); // Enable LightCore
    x.Service(s =>
    {
        s.ConstructUsingLightCore(); // Construct SomeSevice using LightCore
        s.WhenStarted(tc => tc.Start());
        s.WhenStopped(tc => tc.Stop());
        /* more Topshelf code... */
    });
});
    
GitHub