我正在使用 Autofac 到DI并且检测到循环组件依赖性错误
我的实现看起来像
public interface IProduct { }
public class Product : IProduct { }
public interface ISupplier { }
public class Supplier : ISupplier { }
public interface IProductSupplier { }
public class ProductSupplier : IProductSupplier
{
private ProductSupplier(ISupplier supplier, IProduct product) { }
}
public interface IGoodsReceive { }
public class GoodsReceive : IGoodsReceive
{
private GoodsReceive(IProductSupplier productSupplier) { }
}
在解析ProductSupplier时,它会检测到循环组件依赖关系:GoodsReceive - > productSupplier - > productSupplier