/// <summary> /// Initializes a new instance of the <see cref="ServiceModule" /> class. /// </summary> /// <param name="workManagerRegistry">The _work manager registry.</param> /// <param name="notifier">The notifier.</param> /// <param name="disposables">The disposables.</param> /// <param name="onDependencyFactory">The on dependency factory.</param> public ServiceModule( WorkManagerRegistry workManagerRegistry, ILogNotification notifier, IDisposables disposables, Func <IDependencyFactory> onDependencyFactory) : base(workManagerRegistry, notifier, disposables, onDependencyFactory) { }
/// <summary> /// Initializes a new instance of the <see cref="BaseModule" /> class. /// </summary> /// <param name="workManagerRegistry">The work manager registry.</param> /// <param name="notifier">The notifier.</param> /// <param name="disposables">The disposables.</param> /// <param name="onDependencyFactory">The on dependency factory.</param> public BaseModule( WorkManagerRegistry workManagerRegistry, ILogNotification notifier, IDisposables disposables, Func <IDependencyFactory> onDependencyFactory) { _notifier = notifier; _disposables = disposables; _workManagerRegistry = workManagerRegistry; _onDependencyFactory = onDependencyFactory; _workersConfiguration = new SimpleConfigurationSectionManager("workerSettings"); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { var container = (IContainer)null; var workRegistry = new WorkManagerRegistry(); var notifier = new ServiceLogNotification(); var disposables = new Disposables(); var builder = new ContainerBuilder(); builder.RegisterModule(new ServiceModule(workRegistry, notifier, disposables, () => new DependencyFactory(container))); container = builder.Build(); using (var workManager = new WorkManager(workRegistry, new WorkManagerDependencyResolver(container), notifier)) { workManager.OnRuntimeState += (state) => { switch (state) { case ManagerRuntimeStates.Stopped: disposables.Dispose(); break; } }; if (!Environment.UserInteractive) { var servicesToRun = new ServiceBase[] { new WindowsService(workManager) }; ServiceBase.Run(servicesToRun); } else { workManager.Start(); Console.WriteLine($"WorkManager '{WorkManagerConfig.ApplicationName}' has started."); Console.WriteLine("Press any key to terminate..."); Console.ReadKey(); workManager.Stop(); } } }