我继承了一个使用 Castle DI 的项目。我正在向解决方案添加 WCF,并且需要使用解决方案中的一些功能。该类具有以下内容,我假设是注入。
private readonly IOrderRepository _orderRepository;
private readonly IEshopOrderRepository _eShopOrderRepository;
private readonly IUserRepository _userRepository;
private readonly IListRepository _listRepository;
private readonly INHibernateRepositoryWithTypedId<ProductVariant, string> _productVariantRepository;
private readonly IMapper<GiftCardPayment, string, GiftCardPaymentDto> _giftCardDtoMapper;
private readonly IMapper<AbstractOrder, OrderDto> _orderDtoMapper;
private readonly IMapper<AbstractOrder, RecurringOrder> _recurringOrder;
private readonly IMapper<Address, CreditCardPaymentDto> _creditCardDtoMapper;
public delegate OrderDto ShipmentProcessing(OrderDto order, bool isRecap);
public OrderManagementService(IOrderRepository orderRepository, IUserRepository userRepository, IListRepository listRepository,
IEshopOrderRepository eShopOrderRepository,
INHibernateRepositoryWithTypedId<ProductVariant, string> productVariantRepository,
IMapper<GiftCardPayment, string, GiftCardPaymentDto> giftCardDtoMapper,
IMapper<AbstractOrder, OrderDto> orderDtoMapper,
IMapper<AbstractOrder, RecurringOrder> recurringOrder,
IMapper<Address, CreditCardPaymentDto> creditCardDtoMapper)
{
_orderRepository = orderRepository;
_eShopOrderRepository = eShopOrderRepository;
_userRepository = userRepository;
_listRepository = listRepository;
_productVariantRepository = productVariantRepository;
_giftCardDtoMapper = giftCardDtoMapper;
_orderDtoMapper = orderDtoMapper;
_recurringOrder = recurringOrder;
_creditCardDtoMapper = creditCardDtoMapper;
}
所有这些都有效。我的问题是如何在 WCF 服务类中实现这种模式。我无法将参数添加到构造函数,因为客户端不会提供它们。
我能够在 WCF 中使用 DI,因此该部分可以正常工作。
谢谢