2

Is it possible to inject type to using autofac by the caller type?

I have 2 objects that holds the same member type. What I want is when Container1 is called Autofac resolve IRegisteredType as RegisteredType with one value as the name parameter on the ctor and different value for Container2 resolve.

class Container1
{
    private IRegisteredType _registeredType;

    public Container1(IRegisteredType registeredType)
    {
        _registeredType = registeredType;
    }

}

class Container2
{
    private IRegisteredType _registeredType;

    public Container2(IRegisteredType registeredType)
    {
        _registeredType = registeredType;
    }

}

public interface IRegisteredType{}

public class RegisteredType:IRegisteredType
{ 
    public RegisteredType(string name(){...} 
}
Roi Shabtai
  • 2,981
  • 2
  • 31
  • 47

0 Answers0