开发者

Extending web service proxy classes

开发者 https://www.devze.com 2023-03-23 19:06 出处:网络
I need to add functionality to my web service calls so object translation and automatic retries are done and abstracted away.

I need to add functionality to my web service calls so object translation and automatic retries are done and abstracted away.

I would usually override the base class to add the extra functionality, but as the proxy methods aren't over-ridable I can't keep the method names the same. The only other option I can think of to do it this way is to use the 'Shadows' keyword to achieve what I want. Now I don't like the idea of shadows as it isn't particularly OOP, but in this case it seems to make a neat solution.

W开发者_Go百科hat other methods do people use to add functionality to their web service proxy classes without modifying the generated classes?


You can use the Composition over Inheritance principle to achieve this. E.g. write a wrapper around your Web Service to obtain the desired functionality.

Update: code sample

interface IWebService
{
    void DoStuff();
}

public class MyProxyClass
{
    IWebService service;

    public void DoStuff()
    {
        //do more stuff
        service.DoStuff();
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消