[英]How to access overall AutoFac container to register a dependency in Orchard?
the question is pretty straightforward.i want to access overall AutoFac
container so that i can register my dependency in it. 问题非常简单。我想访问整个
AutoFac
容器,以便我可以在其中注册我的依赖项。
remark: 备注:
i am not OK with inheriting from IDependency
cause in my project it results in a circular referencing (of two assemblies).what i wanna do is register a component with a Key and access it with same Key in other assembly. 我不能继承我的项目中的
IDependency
原因导致循环引用(两个程序集)。我想做的是用一个Key注册一个组件并在其他程序集中使用相同的Key访问它。 thanks in advance. 提前致谢。
EDIT: 编辑:
i have found a class called DefaultOrchardHostContainer
in the core ,but it only exposes Resolve<>
method but not Register()
. 我在核心中找到了一个名为
DefaultOrchardHostContainer
的类,但它只暴露了Resolve<>
方法而不暴露了Register()
。
You can add an Autofac module directly to your Orchard module and Orchard will pick it up. 您可以将Autofac模块直接添加到Orchard模块中,Orchard会将其取出。 ex...
恩...
public class MyModule : Module {
protected override void Load(ContainerBuilder builder){
builder.RegisterType<MyDependency>().As<IMyDependency>().InstancePerDependency();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.