I have the following methods, that all return different types. I have four of such methods. In the spirit of good programming practices(DRY), should be using some OOP techniques such as inheritance or interfaces here or just roll with it. Any comments or code examples are welcome. Thank you.
static AttendeeResponse GetAttendees(HttpWebRequest request)
{
HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
try
{
XmlSerializer ser = new XmlSerializer(typeof(AttendeeResponse));
return (AttendeeResponse)ser.Deserialize(resp.GetResponseStream());
}
catch(Exception e)
{
error = e.InnerException.ToString();
return null;
}
}
static MemberResponse GetMembers(HttpWebRequest request)
{
HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
try
{
XmlSerializer ser = new XmlSerializer(typeof(MemberResponse));
return (MemberResponse)ser.Deserialize(resp.GetResponseStream());
}
catch (Exception e)
{
error = e.InnerException.ToString();
return null;
}
}