Skip to content

A topshelf application, easy to deploy, with scheduler, log and dependency injection

Notifications You must be signed in to change notification settings

vittoriazago/topshelfSchedulerIoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Topshelf application with scheduler and depency injection resolution Build Status

A topshelf application, easy to deploy, with scheduler, log and dependency injection

You must install:

In order to create your application you must code a HostFactory Configuration

HostFactory.Run(c =>
            {
                var container = new Container(cfg =>
                {
                    cfg.For(typeof(IRepository<>)).Use(typeof(Repository<>)).AlwaysUnique();
                    cfg.For<NLog.ILogger>().Use(NLog.LogManager.GetCurrentClassLogger()).AlwaysUnique();
                });

                c.UseStructureMap(container);
                c.UseNLog();

                c.Service<MyService>(s =>
                {
                    s.ConstructUsingStructureMap();

                    s.WhenStarted((service, control) => service.OnStart());
                    s.WhenStopped((service, control) => service.OnStop());
                    
                    s.UseQuartzStructureMap();

                    s.ScheduleQuartzJob(q =>
                        q.WithJob(() =>
                            JobBuilder.Create<MyJob>().Build())
                            .AddTrigger(() =>
                                TriggerBuilder.Create()
                                    .WithSimpleSchedule(builder => builder
                                          .WithIntervalInSeconds(5)
                                           .WithRepeatCount(5))
                                    //.WithCronSchedule("")
                                    .Build())
                        );
                });
            });

About

A topshelf application, easy to deploy, with scheduler, log and dependency injection

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages