I have the following inside my ConfigureServices method in the Startup class.
I am adding a singleton instance of ToastNotification which is an implementation of IToastNotification.
public void ConfigureServices(IServiceCollection services)
{
services.AddInstance<IToastNotification>(new ToastNotification()
{
});
}
The problem is that when I watch the value of services while debugging at the end of this method, the implementation type of the IToastNotification service is null. Therefore, when I try to get the Toastnotification instance from the services collection in the controllers, it is always null.
This is how I am getting the Toastnotification using dependency injection
[FromServices]
private IToastNotification ToastNotification { get; set; }
What am I doing wrong?