我使用 Simple Injector 作为我的 IoC 容器。SimpleInjector 使用这种简单的技术来处理 Per Thread 和 Per Web Request 的混合生活方式
container.RegisterPerWebRequest<IWebUnitOfWork, UnitOfWork>();
container.RegisterLifetimeScope<IThreadUnitOfWork, UnitOfWork>();
container.Register<IUnitOfWork>(() => container.GetInstance<UnitOfWork>());
// Register as hybrid PerWebRequest / PerLifetimeScope.
container.Register<UnitOfWork>(() =>
{
if (HttpContext.Current != null)
return container.GetInstance<IWebUnitOfWork>() as UnitOfWork;
else
return container.GetInstance<IThreadUnitOfWork>() as UnitOfWork;
});
我希望用, &之类的IUnitOfWork
类来装饰界面。我应该装饰什么?UnitOfWorkAuthoriseDecorator
UnitOfWorkExceptionDecorator
UnitOfWorkTraceDecorator
IUnitOfWork
IWebUnitOfWork
&IThreadUnitOfWork
IUnitOfWork
&&IWebUnitOfWork
_IThreadUnitOfWork
UnitOfWork
- 别的东西