-
Notifications
You must be signed in to change notification settings - Fork 458
Closed
Description
Hi,
I created an integration for Microsoft.Extensions.DependencyInjection.
You can find the code here: https://gist.github.com/cwe1ss/050a531e2711f5b62ab0
The code is based on the following links:
- https://github.com/autofac/Autofac/tree/master/src/Autofac.Extensions.DependencyInjection
- https://davidzych.com/asp-net-vnext-dependency-injection-with-castle-windsor/
- Castle.Windsor DI container [Working code] dotnet/aspnetcore#263
- https://github.com/davezych/DependencyInjection/tree/windsor/src/Microsoft.Framework.DependencyInjection.Windsor
- http://stackoverflow.com/questions/28353187/how-can-i-get-started-with-asp-net-5-and-castle-windsor-for-dependency-injection
I adjusted the code for RC1 and fixed some issues:
- Components were added with .OnlyNewServices() which resulted in services that are supposed to exist multiple times not being added
- GetService<IEnumerable>() was not resolved properly. I had to add special handling for IEnumerable<>
- ASP.NET Core doesn't expect GetService() to return an exception if the component wasn't registered. (they use it for optional dependencies). For this reason, I added a check to Kernel.HasComponent()
I'm not sure why the call to BeginScope() in Startup.cs is necessary - if it's missing, the first request fails. Seems like ASP.NET Core doesn't start the scope for the first request or some Scoped service is requested before it does.
best regards!
Metadata
Metadata
Assignees
Labels
No labels