如何利用温莎的生活方式管理,但有自己的解决方法?目前我注册我的依赖如下:
_container.Register(Component.For<DbContext>()
.ImplementedBy<EntityContext>().DependsOn(Dependency.OnValue("connectionName", "EntityContext"))
.LifestylePerWebRequest());
Run Code Online (Sandbox Code Playgroud)
我想通过以下 lambda 解决依赖关系:
() => {
return new EntityContext("EntityContext");
}
Run Code Online (Sandbox Code Playgroud)
这怎么能结合?
使用UsingFactoryMethod指定如何创建实例:
container.Register(Component.For<DbContext>()
.UsingFactoryMethod(() => new EntityContext("EntityContext"))
.LifestylePerWebRequest());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
832 次 |
| 最近记录: |