I realise that I saw (very similar) questions being asked, but this seems SLIGHTLY different than the ones usually asked.
I got this notification / notification handler
public class GenericEvent<T> : INotification
{
public T Value { get; set; }
}
public class GenericEventHandler<T> : INotificationHandler<GenericEvent<T>>
{
public Task Handle(GenericEvent<T> notification, CancellationToken ct)
{
throw new NotImplementedException();
}
}
Registering the dependency will give a the following C# compiler error:
CS7003: Unexpected use of an unbound generic name
public static class RegistrationTest
{
public static void Register(IServiceCollection services)
{
services.AddTransient(
typeof(INotificationHandler<GenericEvent<>>), // <!-- CS7003 here
typeof(GenericEventHandler<>));
}
}
I mean of course, the error generated makes sense. But there must be some other way to actually get this registered. FWIW, using the OOTB DI Container
