Last active
May 12, 2019 07:47
-
-
Save sholfen/410567bab2df6085e450c9017cc04b52 to your computer and use it in GitHub Desktop.
DI in ASP.NET MVC Core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (Type type in System.Reflection.Assembly.GetExecutingAssembly().ExportedTypes.Where(t => t.FullName.EndsWith("Service"))) | |
{ | |
if (!type.IsInterface) | |
{ | |
services.AddTransient(type.GetInterfaces().First(), type); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment