From 7c528b06ec27c40d67132d23acc48b4ff5633b0b Mon Sep 17 00:00:00 2001 From: PeterKottas Date: Thu, 29 Dec 2016 08:31:12 +0100 Subject: [PATCH] Extra arguments passed to service factory --- README.md | 2 +- Source/PeterKottas.DotNetCore.Example/Program.cs | 2 +- .../Configurators/Service/ServiceConfigurator.cs | 2 +- .../PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs | 2 +- .../PeterKottas.DotNetCore.WindowsService.nuspec | 2 +- Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5ed0cb6..deeee13 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ Using nuget: var name = config.GetDefaultName(); config.Service(serviceConfig => { - serviceConfig.ServiceFactory(() => + serviceConfig.ServiceFactory((extraArguments) => { return new ExampleService(); }); diff --git a/Source/PeterKottas.DotNetCore.Example/Program.cs b/Source/PeterKottas.DotNetCore.Example/Program.cs index cf33442..992ddf5 100644 --- a/Source/PeterKottas.DotNetCore.Example/Program.cs +++ b/Source/PeterKottas.DotNetCore.Example/Program.cs @@ -15,7 +15,7 @@ public static void Main(string[] args) var name = config.GetDefaultName(); config.Service(serviceConfig => { - serviceConfig.ServiceFactory(() => + serviceConfig.ServiceFactory((extraArguments) => { return new ExampleServiceTimer(); }); diff --git a/Source/PeterKottas.DotNetCore.WindowsService/Configurators/Service/ServiceConfigurator.cs b/Source/PeterKottas.DotNetCore.WindowsService/Configurators/Service/ServiceConfigurator.cs index 0dd2dbf..8adbfe9 100644 --- a/Source/PeterKottas.DotNetCore.WindowsService/Configurators/Service/ServiceConfigurator.cs +++ b/Source/PeterKottas.DotNetCore.WindowsService/Configurators/Service/ServiceConfigurator.cs @@ -12,7 +12,7 @@ public ServiceConfigurator(HostConfiguration config) this.config = config; } - public void ServiceFactory(Func serviceFactory) + public void ServiceFactory(Func, SERVICE> serviceFactory) { config.ServiceFactory = serviceFactory; } diff --git a/Source/PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs b/Source/PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs index a31fde2..9f8b534 100644 --- a/Source/PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs +++ b/Source/PeterKottas.DotNetCore.WindowsService/HostConfiguration.cs @@ -31,7 +31,7 @@ public HostConfiguration() public SERVICE Service { get; set; } - public Func ServiceFactory { get; set; } + public Func, SERVICE> ServiceFactory { get; set; } public Action> OnServiceStart { get; set; } diff --git a/Source/PeterKottas.DotNetCore.WindowsService/PeterKottas.DotNetCore.WindowsService.nuspec b/Source/PeterKottas.DotNetCore.WindowsService/PeterKottas.DotNetCore.WindowsService.nuspec index 826676d..9bf29f4 100644 --- a/Source/PeterKottas.DotNetCore.WindowsService/PeterKottas.DotNetCore.WindowsService.nuspec +++ b/Source/PeterKottas.DotNetCore.WindowsService/PeterKottas.DotNetCore.WindowsService.nuspec @@ -3,7 +3,7 @@ PeterKottas.DotNetCore.WindowsService PeterKottas.DotNetCore.WindowsService - 1.0.4 + 1.0.5 Peter Kottas Easiest to use library that allows one to host .net core as windows services there is. .NET Core Windows service diff --git a/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs b/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs index 979add3..740e082 100644 --- a/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs +++ b/Source/PeterKottas.DotNetCore.WindowsService/ServiceRunner.cs @@ -123,7 +123,7 @@ public static int Run(Action> runAction) try { runAction(hostConfiguration); - innerConfig.Service = innerConfig.ServiceFactory(); + innerConfig.Service = innerConfig.ServiceFactory(innerConfig.ExtraArguments); ConfigureService(innerConfig); return 0; }