检测到循环组件依赖:

时间:2016-04-14 09:13:39

标签: c# dependency-injection autofac

我正在使用 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

0 个答案:

没有答案