为什么不使用IoC容器来解决实体/业务对象的依赖关系?
public class Order : IOrder { private string _ShipAddress; private IShipQuoter _ShipQuoter; public Order(IOrderData OrderData, IShipQuoter ShipQuoter) { // OrderData comes from a repository and has the data needed // to construct order _ShipAddress = OrderData.ShipAddress; // etc. _ShipQuoter = ShipQuoter; } private decimal GetShippingRate() { return _ShipQuoter.GetRate(this); } }
相关分类