0
를 통해 노출 단일 인스턴스 개체에 대한 사용자 정의 대리자를 아래의 코드를 생각해 나는 ProductFactory
대리자를 호출하여 사람에 의해 작성 될 IProduct
에 대한 단일 인스턴스를 관리 할 필요가Autofac : 인터페이스
public interface IProduct { };
public class ConcreteProduct : IProduct
{
public ConcreteProduct(int id, DateTime manufacturedDate, DateTime expiryDate)
{
}
}
public delegate IProduct ProductFactory(int id, DateTime manufacturedDate, DateTime expiryDate);
을, ConcreteProduct
을 반환합니다.
이 기능을 Autofac과 함께 사용하는 방법을 제안하십시오.
데이터 객체 (예 : DTO, 엔터티 및 메시지)를 작성하는 것은 Autofac의 작업이 아닙니다. DI 컨테이너의 역할은 응용 프로그램 구성 요소 (응용 프로그램의 동작을 유지하는 클래스)의 객체 그래프를 작성하는 것입니다. – Steven