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()
.
From Visual Studio, you can get it via NuGet. The package name is Autofac. Alternatively, the NuGet package can be downloaded from the GitHub repository (https://github.com/autofac/Autofac/releases).
Autofac is an addictive IoC container for . NET. It manages the dependencies between classes so that applications stay easy to change as they grow in size and complexity. This is achieved by treating regular . NET classes as components.
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();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With