0
在WCF客户端启动之后让WCF主机访问多个数据库而不传递名称的最佳方式是什么?我使用DI和想要做的事,如:一个WCF服务和多个数据库连接
wcfCourseManagement.CourseManagementClient _wcfclient = null;
public WCFCourseRepository(ISystemService systemService): base(systemService)
{
_wcfclient = new wcfCourseManagement.CourseManagementClient();
ServiceEndpoint endpoint = systemService.GetServiceEndpoint("CourseManagement");
if (endpoint != null)
_wcfclient.Endpoint.Address = new EndpointAddress(new Uri(endpoint.Endpoint));
if (_wcfclient.GetRemoteSystemID != systemService.ClientSystem.PreferredRemoteSystemID)
_wcfclient.SetCurrentSystem(systemService.ClientSystem.PreferredRemoteSystemID);
}
的SetCurrentSystem会告诉WCF主机,它应该重建数据仓库如果需要的话。系统ID只是一个ID,存放在服务器用来加载数据库配置信息的配置存储中。但是,由于WCF主机接线的设计,在主机的无参数构造期间注入了“默认”SystemID。我想覆盖它,但是我不希望在每次调用时都传递它,因为这会破坏当前的存储库接口,由客户端和服务器代码共享。什么是完成这种行为最直接的方式?
谢谢,看起来像一个伟大的文章。 – kgc 2011-06-14 21:17:27