DI / IoC
port my DI doc from HTML to reStructuredText
looking forward to it :dancers:
ASP.NET 5->Runtime->Dependency Injection •Adding services: singleton, scoped, transient •Default behavior: constructor injection •Using a your favorite IoC Container
Waiting with bated breath for the Using your favorite IoC container info.
@tdietrich513 While you are waiting check out what the Autofac guys published on how to use Autofac with ASP.NET 5: http://alexmg.com/autofac-4-0-alpha-1-for-asp-net-5-0-beta-3/
Nice- my preferred container is Windsor but maybe I can hack out an implementation until they get on their game.
Planning on starting this today/tomorrow, @danroth27. Update TOC if necessary and/or set up a meeting to discuss, please. Otherwise planning on working from Rick's DI/IOC article as a base.
How to get framework services from DI
- Ex ILoggerFactory
- Ex DbContext
How to add services to the DI system
- Ex Repository pattern that injects the DbContext
- Service lifetime: transient, scoped, singleton
- Registration: type, factory, instance
Request services vs application services
Core services available from hosting during startup
- IHostingEnvironment
- ILoggerFactory
- IApplicationEnvironment
- ??
Replacing the default IoC container with your favorite one
- Example: https://github.com/aspnet/Mvc/blob/dev/samples/MvcSample.Web/Startup.cs
- http://www.nuget.org/packages/Autofac.Dnx/4.0.0-alpha2
What should go in DI?
- DI is for creating objects with complex dependencies, not for storing application data
- Ex you wouldn't put the user's shopping cart in DI, you might put a shopping cart factory
Anti-patterns
- Static access to services or HttpContext
@danroth27 How i can help write this documentation?
@nicolastakashi you can review my PR that's coming shortly
@ardalis Seems great!
Do you wanna talk by skype or email? How do you prefer?
@nicolastakashi I think just using PR comments (once I get the PR done in a few days) will work fine.
Hello, I'm very interested in reviewing any early material on how the Dependency Injection module that will be a part of ASP.NET 5.0 is going to be working. I'm happy to spend a little extra time making notes to the author. My intention is to jump into ASP.NET 5.0 a lot earlier than I've jumped into previous bleeding edge .net releases, so feel free to utilize me to bounce revisions off.
@mattchristenson @nicolastakashi shoot me an email [email protected] and I'll send you the latest version (in a zipped HTML file). You can then comment on this PR