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

Popular posts from this blog

python - Why doesn't list have safe "get" method like dictionary? -

razor - Is this a bug in WebMatrix PageData? -

sql server - Stored procedure -