我在一个名为 CCL.Data 的单独程序集中有我的服务层、实体和 DTOS
问题:
我的所有应用程序都直接使用接口和 IoC 引用服务层。
例如,我的 CCL.Data 程序集中有一个名为 ICustomerService 的接口,它依赖于依赖于 MyContext 的 ICustomerRepository。我所有的应用程序都在引用 ICustomerService 来调用它的方法.......到目前为止没问题。
所以我创建了一个 WCF 项目....在这个项目中引用 CCL.Data....
我创建了一个新服务,但在下面的这种情况下,我需要将我的应用程序中调用 ICustomerService 的所有点更改为 WCFCustomerServiceClient,是否存在更好的方法而不会对我的项目造成重大影响?
[服务合同]
公共接口 IWCFCustomerService
{
[运营合同]
CustomerDTO GetCustomerById(int id);
}
公共类 WCFCustomerService : IWCFCustomerService
{
ICustomerService _customerService;
公共 WCFCustomerService()
{
MyContext 上下文 = new MyContext();
ICustomerRepository customerRep = new CustomerRepository(context);
_customerService = new CustomerService(customerRep);
}
公共 CustomerDTO GetCustomerById(int id)
{
返回 _customerService.GetCustomerById(id);
}
}
Tks,威廉