c# - I want to convert all my classes in Generic classes then call classes methods -
i want use generics able use proxy
kind of realclient
.
public interface iclient { string getdata(); } public class realclient : iclient { string data; public realclient() { console.writeline("real client: initialized"); data = "success"; } public string getdata() { return data; } } public class proxy : iclient { realclient _classobject = new realclient(); public proxy() { console.writeline("proxyclient: initialized"); } public string getdata() { return _classobject.getdata(); } } class program { static void main(string[] args) { proxy proxy = new proxy(); console.writeline("data proxy client = {0}", proxy.getdata()); console.readkey(); } }
it seems you're trying implement proxy design pattern, , want proxy work kind of iclient
.
if so, don't need generics this. you'd implement proxy:
public class proxy : iclient { private readonly iclient _client; public proxy(iclient client) { _client = client; console.writeline("proxyclient: initialized"); } public string getdata() { return _client.getdata(); } }
keep simple.
Comments
Post a Comment