1
我可以在溫莎城堡做到這一點:是否可以使用Unity將參數注入受保護的構造函數?
public abstract class AbstractFactory
{
protected AbstractFactory(Foo constructorParm)
{
// Do something with parameter...
}
}
public class DescendentFactory : AbstractFactory
{
public DescendentFactory(Foo constructorParm) : base(constructorParm)
{
}
}
// The container is configured via XML, the service AbstractFactory and the
// type DescendentFactory
container.Resolve<AbstractFactory>("DescendentFactoryId", new { constructorParm = injectedValue });
這是可能的團結?我試過這樣做,但它抱怨說它無法找到構造函數。看來我只能通過子類型注入。