.net 3.5 - Interface for two almost identical web references in C# -
i have 2 web refs can't change:
they identical when referenced 1 accepts propercase , other uppercamelcase.
example
not props thing entire classes props , methods
@edit: sorry, i've realized it's more complicated stated:
not props thing entire classes props , methods and inner classes. although used structures, inner classes have same issue.
public class foobar { public string logmsgno; public string revno; public string reqsox; public void dosomething(); public barbaz mybarbaz; public list<quux> myquuxlist; } and other has names like
public class foobar { public string logmsgno; public string revno; public string reqsox; public void dosomething(); public barbaz mybarbaz; public list<quux> myquuxlist; } is there easy way make interface both?
tia!
without proper re-factoring update , changing names, yes, little bit of smoke , mirrors. create interface based on new values want them be, change them respectively use getter/setter retain original , not break it.
to expand expanded question. have adjust each of levels too.. define interface "barbaz" , "barbaz" class outer class can have object of
public interface iyourbarbazinterface { string barbazprop1 { get; set; } string anotherprop { get; set; } } public interface iquux { int quuxprop { get; set; } string anotherquuxprop { get; set; } } public interface iyourcommoninterface { string logmsgno { get; set; }; string revno { get; set; }; string reqsox { get; set; }; // similar principle of declarations, interface typed objects iyourbarbazinterface mybarbaz { get; set; } list<iquux> myquuxlist; void dosomething(); } public class foobar : iyourcommoninterface { public string logmsgno; public string revno; public string reqsox; public void dosomething(); // existing old versions keep same name context // showing each of respective common "interfaces" public iyourbarbazinterface mybarbaz; public list<iquux> myquuxlist = new list<iquux>(); // these implementations of interface... public string logmsgno { { return logmsgno; } set { logmsgno = value; } } public string revno { { return revno; } set { revno = value; } } public string reqsox { { return reqsox; } set { reqsox = value; } } public void dosomething() { dosomething(); } // now, publicly common interface of "iyourcommoninterface" // identify common elements common naming constructs. // similar in second class. public iyourbarbazinterface mybarbaz { { return mybarbaz; } set { mybarbaz = value; } } public list<iquux> myquuxlist { { return myquuxlist; } set { myquuxlist = value; } } } public class foobar : iyourcommoninterface { // since version has proper naming constructs want, // change original properties lower case start character // interface required getter/setter qualified public string logmsgno; public string revno; public string reqsox; public iyourbarbazinterface mybarbaz; public list<iquux> myquuxlist; // these implementations of interface... public string logmsgno { { return logmsgmo; } set { logmsgno = value; } } public string revno { { return revno; } set { revno = value; } } public string reqsox { { return reqsox; } set { reqsox = value; } } // since "dosomething()" method proper case-sensitive // format, can leave version alone public void dosomething() { .. whatever .. } public iyourbarbazinterface mybarbaz { { return mybarbaz; } set { mybarbaz = value; } } public list<iquux> myquuxlist { { return myquuxlist; } set { myquuxlist = value; } } }
Comments
Post a Comment