How to access overall AutoFac container to register a dependency in Orchard?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 17:45:12

问题


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

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

EDIT:

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


回答1:


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();
   }
}


来源:https://stackoverflow.com/questions/13584085/how-to-access-overall-autofac-container-to-register-a-dependency-in-orchard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!