Skip to content

Topshelf.Unity provides extensions to construct your service class from your Unity IoC container.

License

Notifications You must be signed in to change notification settings

Kesmy/Topshelf.Unity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Topshelf.Unity

Topshelf.Unity provides extensions to construct your service class from your Unity IoC container.

Install

It's available via nuget package
PM> Install-Package Topshelf.Unity

Example Usage

static void Main(string[] args)
{
        // Create your container
        var container = new UnityContainer();
        container.RegisterType<ISampleDependency, SampleDependency>();
        container.RegisterType<SampleService>();

        HostFactory.Run(c =>
        {
            // Pass it to Topshelf
            c.UseUnityContainer(container);

            c.Service<SampleService>(s =>
            {
                // Let Topshelf use it
                s.ConstructUsingUnityContainer();
                s.WhenStarted((service, control) => service.Start());
                s.WhenStopped((service, control) => service.Stop());
            });
        });
}

About

Topshelf.Unity provides extensions to construct your service class from your Unity IoC container.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 94.9%
  • Batchfile 5.1%