如何访问整体AutoFac容器中注册果园的依赖? [英] How to access overall AutoFac container to register a dependency in Orchard?

查看:165
本文介绍了如何访问整体AutoFac容器中注册果园的依赖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是pretty straightforward.i要访问的总体 AutoFac 容器,这样我可以在里面注册我的依赖关系。

the question is pretty straightforward.i want to access overall AutoFac container so that i can register my dependency in it.

注:

我不从 IDependency 事业我的项目它会导致循环引用(两集)。什么我想要做的继承确定是注册一个组件密钥和与其他组件相同的密钥访问它。
先谢谢了。

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. thanks in advance.

编辑:

我已经找到了一个名为 DefaultOrchardHostContainer 中的核心类,但它仅公开解析<> 方法,但没有寄存器()

i have found a class called DefaultOrchardHostContainer in the core ,but it only exposes Resolve<> method but not Register().

推荐答案

您可以直接添加Autofac模块的果园模块和乌节将它捡起来。恩...

You can add an Autofac module directly to your Orchard module and Orchard will pick it up. ex...

public class MyModule : Module {
   protected override void Load(ContainerBuilder builder){
      builder.RegisterType<MyDependency>().As<IMyDependency>().InstancePerDependency();
   }
}

这篇关于如何访问整体AutoFac容器中注册果园的依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆