c# - Generic method calling duplication -
i have following code:
switch (objecttype) { case objecttype.userreview: return mymethod<userreview>(); case objecttype.professionalreview: return mymethod<professionalreview>(); case objecttype.question: return mymethod<question>(); case objecttype.news: return mymethod<news>(); default: throw new argumentoutofrangeexception("objecttype"); }
now need same code calling method. there options implement without duplication , reflection?
sounds ideal opportunity replace conditional polymorphism. can promote objecttype.userreview
class (it looks enum
@ moment) , put switch block polymorphic method?
Comments
Post a Comment