我必須創建一個具有五個不同組件的WCF服務。每個組件都有一個接口,每個組件都有其具體的實現。所有這五個接口組合在一起使我的應用程序。WCF服務可以組成各種界面嗎?
我不知道我是否應該創建5個獨立的WCF服務,客戶端可以調用。雖然他們是獨立的,並有單一的責任,但我試圖避免創建5個服務,因爲這將是託管,部署和維護的矯枉過正。另外他們是相當輕的重量。 所以我想問你的意見和建議嗎?
我是否應該創建一個大型接口來實現所有其他五個接口以及具有所有接口功能的具體實現,例如,
public interface IMainInterface: IComponent1, IComponent2, IComponent3, IComponent4, IComponent5 { region implementation of IComponent1 public void CallMethod(){...} endregion region implementation of IComponent2 endregion //and so on }
將它不會弄亂的具體實施,因爲實施component1..5的將是IMainInterface的實現裏面?
我應該有五個接口作爲主要接口的屬性,並創建我的實現調用五個實現例如方法public方法
public interface IMainInterface { public IComponent1 Component1 {get;set;} public IComponent2 Component1 {get;set;} public IComponent3 Component1 {get;set;} public IComponent4 Component1 {get;set;} public IComponent5 Component1 {get;set;} }
它沈志南實施,將是這樣的:
public class Main:IMainInterface { public void CallComponent1Method() { Component1.CallMethod(); } }
你會建議或者是沒有辦法,我可以採取另一種方法哪種方法?
難道它不會混淆具體實現,因爲我將不得不將所有組件的concerete實現添加到主要組件中。 – InfoLearner
@KnowledgeSeeker,是的,但這就是WCF的工作原理。如果您定義另一個WCF服務的另一個接口(服務契約)。 –
謝謝。所以你說「大否」最後的做法。 – InfoLearner