2

是否可以通过调用者类型注入类型以使用 autofac?

我有 2 个拥有相同成员类型的对象。我想要的是什么时候Container1被称为 Autofac 解析IRegisteredTypeRegisteredType其中一个值作为解析的name参数ctor和不同 的值Container2

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(){...} 
}
4

0 回答 0