0
我会尽力解释我想要的代码,原因不能用文字来表达。如何实现封装其他WCF服务的WCF服务的概念?
我有一些类型的资源,我封装及其使用的WCF服务,我有控制访问该资源的资源管理器,它也是一个WCF服务,像这样:
//Allows only one client to use it at the same time...
public interface IResource
{
string GetResourceDescription();
void DoWork();
void BeginWork();
void EndWork();
}
//Governs access and location of resources
public interface IResourceManager
{
IEnumerable<string> GetResourcesDescriptions();
bool IsResourceAvailable(string resourceDescription);
void BeginWorkWith(string resourceDescription);
void DoWorkWith(string resourceDescription)
void EndWorkWith(string resourceDescription);
}
我不要在此代码一样的是,与IResourceManager
工作时,我需要总是告诉我要使用业务操作有什么资源,所以基本上IResourceManager
具有相同的服务操作为IResource
但需要额外的IResource
标识符作为参数。
我要的是:
public interface IResourceManager
{
IEnumerable<string> GetResourcesDescriptions();
//I want it to return service proxy (ICommunicationObject)
IResource GetResource(string resourceDescription);
}
首先这是不可能的,第二,客户端不能与IResource
直接在网络层进行通信(没有直接连接)。
到目前为止,我只找到一个没有丑陋的解决方案,创建一个客户端的包装,模仿这种行为。如何实现和使用这样的WCF服务?