fix: registration
This commit is contained in:
@@ -6,13 +6,13 @@ public class HostedServiceRegistrator
|
||||
{
|
||||
public void RegisterHostedService(IServiceCollection services, Type hostedServiceType)
|
||||
{
|
||||
Type servicesType = typeof(HostedServiceRegistrator);
|
||||
MethodInfo methodInfo = servicesType.GetMethod("AddHostedService");
|
||||
MethodInfo genericMethod = methodInfo.MakeGenericMethod(hostedServiceType);
|
||||
var servicesType = typeof(HostedServiceRegistrator);
|
||||
var methodInfo = servicesType.GetMethod(nameof(AddHostedService));
|
||||
var genericMethod = methodInfo.MakeGenericMethod(hostedServiceType);
|
||||
|
||||
genericMethod.Invoke(this, new object[] { services });
|
||||
}
|
||||
|
||||
// Needed as a work-arround because we can't call the extension method with reflection.
|
||||
public IServiceCollection AddHostedService<THostedService>(IServiceCollection services)
|
||||
where THostedService : class, IHostedService =>
|
||||
services.AddHostedService<THostedService>();
|
||||
|
||||
Reference in New Issue
Block a user