How can I resolve a service manually in a Web API project using Autofac. I have a class called Foo. Foo is instantiated by Activator.CreateInstance by another class that I have no control over, which means it would call the paramaterless constructor.
I have a few properties that need to be injected in the Foo class. Now since the calling class calls the paramaterless constructor, I need to resolve these properties manually.
public class Foo
{
private IService Instance;
public Foo()
{
//How do I get the per request lifetime scoped dependency resolver here
IService = (Dependency Resolver).Resolve<IService>();
}
}
Aucun commentaire:
Enregistrer un commentaire