我被稱爲!?!?! :-)
如果你有一個接口
public interface IServiceA
{
void Method_A();
void Method_B();
void Method_X1();
}
,你完全可以共享的實現代碼在服務器端的兩種常用方法的第二個
public interface IServiceB
{
void Method_A();
void Method_B();
void Method_X2();
}
。
你會在一個共同的類庫創建兩個類MethodAHandler
和MethodBHandler
您的服務器上(或在兩個單獨的,常見的組件),然後你可以使用類似:
using MethodHandlers; // contains the two method handlers
public class ServiceA : IServiceA
{
public void Method_A()
{
MethodAHandler hnd = new MethodAHandler();
hnd.HandleMethodCall();
}
public void Method_B()
{
MethodBHandler hnd = new MethodBHandler();
hnd.HandleMethodCall();
}
public void Method_X1()
{
// handle method X1 call here or delegate to another handler class
}
}
,爲第二個服務:
using MethodHandlers; // contains the two method handlers
public class ServiceB : IServiceB
{
public void Method_A()
{
MethodAHandler hnd = new MethodAHandler();
hnd.HandleMethodCall();
}
public void Method_B()
{
MethodBHandler hnd = new MethodBHandler();
hnd.HandleMethodCall();
}
public void Method_X2()
{
// handle method X2 call here or delegate to another handler class
}
}
在服務器端,你有.NET類,你可以通過絕對共同的類庫來分享兩個獨立的服務實現之間的代碼或任何你找到最好的方法您。
這看起來非常好......謝謝......我會試一試並回復給您 – Learner 2011-04-07 15:40:26
說實話,對於給定的情況,您的解決方案是好的。我只是試圖找出什麼解決方案是最好的和靈活的時候去真實世界的應用程序......你會如何比較你的解決方案marc的?無論你想到什麼想法......寫下來,謝謝! – Learner 2011-04-08 09:02:23
我接受你的回答,因爲這是正確的,可能會幫助其他人。但我想要更多的東西的觀點,而不是解決方案。無論如何,謝謝。 – Learner 2011-05-03 14:35:21