我有三个类实现它们的接口。用依赖注入解决循环依赖问题
订单
public interface IOrderService
{
//SomeOrderFunction()
}
public class OrderService: IOrderService
{
//SomeOrderFunction();
}
驱动程序
public interface IDriverService
{
//SomeDriverFunction()
}
public class DriverService: IDriverService
{
//SomeDriverFunction();
}
计划 - 使用驱动程序和计划服务
public interface IPlanService
{
//SomePlanFunction()
}
public class PlanService: IPlanService
{
private readonly IOrderService _orderService;
private readonly IDriverService _driverService;
public PlanService(IDriverService driverService, IOrderService orderService)
{
_orderService = orderService;
_driverService = driverService;
}
//PlanFunctionsThatUseServices();
}
的问题,我现在虽然是订单和驱动程序服务需要当订单或驱动程序发生变化时,请回复计划服务,我该如何去做这件事没有循环依赖?
编辑: 具体来说,我一直在寻找创造,管理所有其他的人,如一个在这篇文章中解释第四服务。
什么混淆了我这个实现我的计划类,不我的计划类实现两个新的类和接口IPLAN?
我不认为没有这个参考是可能的。或者,您可以创建管理三种服务之间通信的_fourth_类。 – rbm