Created
May 15, 2011 04:54
Revisions
-
cammerman revised this gist
May 15, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,10 @@ enum EContainerContext MultiInstanceWindow } // Registration code for an object that owns a lifetime scope builder.RegisterType<MyDbContext>() .As<DbContext>(); builder.RegisterType<UnitOfWork>() // Has dependency on DbContext. .As<IUnitOfWork>() .EstablishesLifetimeScope() // Desired syntax. Indicates each new UnitOfWork should have a new lifetime scope bound to the life of the object. Also implies the UnitOfWork itself has per-dependency lifetime scope. Each time requested outside the bound lifetime scope, a new one is created. -
cammerman created this gist
May 15, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ // Container context tags enum EContainerContext { UnitOfWork, Plugin, MultiInstanceWindow } builder.RegisterType<MyDbContext>() .As<DbContext>(); // Registration code for an object that owns a lifetime scope builder.RegisterType<UnitOfWork>() // Has dependency on DbContext. .As<IUnitOfWork>() .EstablishesLifetimeScope() // Desired syntax. Indicates each new UnitOfWork should have a new lifetime scope bound to the life of the object. Also implies the UnitOfWork itself has per-dependency lifetime scope. Each time requested outside the bound lifetime scope, a new one is created. .WithTag(EContainerContext.UnitOfWork); // Desired syntax. Specifies the tag to attach to the generated lifetime scope. builder.RegisterType<DomainType1Repository>() // Has dependency on IUnitOfWork. .As<IRepository<DomainType1>>() .InstancePerMatchingLifetimeScope(EContainerContext.UnitOfWork); builder.RegisterType<DomainType2Repository>() // Has dependency on IUnitOfWork. .As<IRepository<DomainType2>>() .InstancePerMatchingLifetimeScope(EContainerContext.UnitOfWork);