Hi !
I have several web references in my project .
I created a new class that inherit from those web reference class and I
override GetWebResponse from each of those web reference class.
For instance
public class UserServiceProxy : .UserService
{
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest)base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion = HttpVersion.Version10;
return webRequest;
}
}
How do it prevent code repetition like this in every proxy class that inherit from the web reference
Thanks
Loading

CrishRank #1,487 · 1.1K reputationPosted Dec 13, 2010, 12:03 AM EST
You can refer this following example to solve the issue of overriding the same method without code duplication.It will help you.
class Base { public: virtual commonFunction() { /* default implementation */ }; }; class Mixin { public: virtual notSoCommonFunction() { /* default implementation */ }; }; class D1 : public Base { public: virtual commonFunction() { /* override implementation */ }; }; class D2 : public Base, public Mixin { public: virtual commonFunction() { /* override implementation */ }; virtual notSoCommonFunction() { /* override implementation */ }; }; class D3 : public Base, public Mixin { public: virtual commonFunction() { /* override implementation */ }; virtual notSoCommonFunction() { /* override implementation */ }; }; Otherwise check this below link. http://stackoverflow.com/questions/1022242/overriding-same-method-in-only-some-child-classes-how-to-avoid-duplication