25 lines
725 B
C#
25 lines
725 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using xCommons.Providers;
|
|
|
|
namespace xCommons.Extensions
|
|
{
|
|
public static class BackgroundServiceExtensions
|
|
{
|
|
/// <summary>
|
|
/// Register Background Services ...
|
|
/// </summary>
|
|
/// <typeparam name="TService"></typeparam>
|
|
/// <param name="source"></param>
|
|
/// <param name="service"></param>
|
|
public static void AddXBackgroundService<TService>(
|
|
this IServiceCollection source,
|
|
TService service
|
|
)
|
|
where TService : XBackgroundService
|
|
{
|
|
//
|
|
source.AddSingleton(service);
|
|
source.AddHostedService<TService>();
|
|
}
|
|
}
|
|
} |