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服務?