-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBasicServiceHandler.cs
More file actions
28 lines (25 loc) · 1.1 KB
/
BasicServiceHandler.cs
File metadata and controls
28 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Reflection;
using Simplify.System;
namespace Simplify.WindowsServices;
// ReSharper disable once CommentTypo
/// <summary>
/// Provides class which runs as non-timer windows service (for constant async operations, like TCP/IP server) and launches specified type instance once
/// </summary>
public class BasicServiceHandler<T> : MultitaskServiceHandler
where T : class
{
/// <summary>
/// Initializes a new instance of the <see cref="BasicServiceHandler{T}" /> class.
/// </summary>
/// <param name="automaticallyRegisterUserType">if set to <c>true</c> then user type T will be registered in DIContainer with transient lifetime.</param>
/// <param name="invokeMethodName">Name of the invoke method.</param>
/// <param name="startupArgs">The startup arguments.</param>
public BasicServiceHandler(bool automaticallyRegisterUserType = false,
string invokeMethodName = "Run",
object? startupArgs = null)
{
var assemblyInfo = new AssemblyInfo(Assembly.GetCallingAssembly());
ServiceName = assemblyInfo.Title;
AddBasicJob<T>(automaticallyRegisterUserType, invokeMethodName, startupArgs);
}
}