Single endpoint with multiple service contracts

╄→гoц情女王★ 提交于 2019-12-01 05:48:25

I have given the below example is it what you were looking for?

[ServiceContract]
public interface IWirelessService : IInternetService
{
    [OperationContract]
    Connection AddInternet();
}

[ServiceContract]
public interface IWiredService : IInternetService
{
    [OperationContract]
    Connection AddInternet();
}

public class WirelessService : IWirelessService 
{
   public Connection AddInternet()
   {
   //Get Internet the wireless way
   }

}

public class WiredService : IWiredService 
{
    public Connection AddInternet()
    {
    //Get Internet the wired way
    }
}

[ServiceContract]
public interface IInternetService
{
    [OperationContract]
    Connection AddInternet();
}


[ServiceContract]
public interface IEnterpriseApplicationService
{
    [OperationContract]
    void GetDataFromInternet(string url, IInternetService internetService);
}
public class InternetProviderService : IEnterpriseApplicationService
{ 
    public HTMLResponse GetDataFromInternet(string url, IInternetService internetService)
    {
       Connection con = internetService.AddInternet();
       return con.GetContentFromURL(url);
    }
 }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!