답변

3

는 당신이 직접 할 수 있다면 모르겠지만, 난 당신이 다음을 수행하여 비슷한 달성 할 수 있다고 생각 :

public interface IMyType 
{ 
    //whatever you need 
} 

public interface IMyTypeProvider 
{ 
    IMyType Create(object context); 
} 

public class MyTypeProvider : IMyTypeProvider 
{ 
    public IMyType Create(object context) 
    { 
     //construct required instance based on context 
    } 
} 

public class ClassWhichNeedsMyType 
{ 
    public ClassWhichNeedsMyType(IMyTypeProvider provider) 
    { 
     this.myType = provider.Create(this); 
    } 

    private IMyType myType; 
} 

가 다음 컨테이너와 공급자를 등록하고 구성하기 위해 그것을 사용하여 종속성 :

container.RegisterType<IMyTypeProvider, MyTypeProvider>(); 
+0

감사합니다. 비슷한 접근 방식을 사용했습니다. – devdigital

관련 문제