Skip to content

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

License

Notifications You must be signed in to change notification settings

Hobbs1210/Topshelf.Lamar

Repository files navigation

Topshelf.Lamar

Build status NuGet Version NuGet Downloads

Topshelf.Lamar is a collection of packages that extend the Topshelf Project. These packages handle the boiler plate code necessary for several use cases that we have found very useful for quickly developing small self contained services on Windows.

These packages solve these problems by integrating the following technologies with Topshelf and providing extensions to quickly integrate them.

Getting Started

The packages are available on Nuget and can be used in any combination desired. The Lamar package is directly integrated with Topshelf, and also has accompanying packages for Quartz.Net projects to make it possible to initiate Quartz.NET IJob instances via the container.

Topshelf.Ninject

To get the package: Install-Package Topshelf.Lamar

To use Lamar with your Topshelf service, all you need is :

using Topshelf.Lamar;

...

class Program
{
    static void Main()
    {
        HostFactory.Run(c =>
        {
            c.UseLamar( new Container());

            c.Service<SampleService>(s =>
            {
                s.ConstructUsingLamar(); 
                s.WhenStarted((service, control) => service.Start());
                s.WhenStopped((service, control) => service.Stop());
            });
        });
    }
}

Topshelf.Quartz.Lamar

To get the package: Install-Package Topshelf.Quartz.Lamar

To use Lamar with your Topshelf service and Quartz, all you need is :

using Topshelf.Lamar;
using Topshelf.Quartz.Lamar

...

class Program
{
    static void Main()
    {
        HostFactory.Run(c =>
        {
            c.UseLamar( new Container());

            c.Service<SampleService>(s =>
            {
                s.ConstructUsingLamar(); 
                s.WhenStarted((service, control) => service.Start());
                s.WhenStopped((service, control) => service.Stop());

				s.UseQuartzLamar();

				s.ScheduleQuartzJob(q =>
                    q.WithJob(() => JobBuilder.Create<SampleJob>().WithIdentity("SampleJob").Build())
                        .AddTrigger(() => TriggerBuilder.Create().WithSimpleSchedule(builder => builder.WithIntervalInSeconds(5).RepeatForever()).Build())
                    );
            });
        });
    }
}

References

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages