Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How can i Inject a collection in .Net core MVC constructor injection

$
0
0

I have a contract(interface) called INotifier and implmented it in two classes SMSNotifier and EmailNotifier. Now i want to inject these two implementations as an array of dependencies to INotifier[]. 

like this 

private readonly INotifier[] _notifiers;

public AccountController(INotifier[] notifiers)

{

_notifiers=notifiers;

}

How can i add dependency for  this scenario in ServiceCollection (Startup Class);


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>