问题
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