c# - Is there any way I could simplify this code using more generics? -


i've tried simplify can't think of way make simpler. there lot more of these rows 1 every table access. suggestions?

public static iazuretable<sequence> getsequencetable(string datastorevalue) {     var sequencetable = new azuretable<sequence>(getstorageaccount(datastorevalue), "sequences");     return (sequencetable); } public static iazuretable<topic> gettopictable(string datastorevalue) {     var topictable = new azuretable<topic>(getstorageaccount(datastorevalue), "topics");     return (topictable); } public static iazuretable<test> gettesttable(string datastorevalue) {     var testtable = new azuretable<test>(getstorageaccount(datastorevalue), "tests");     return (testtable); } 

here's more reference. not wanting change add it:

 public class azuretable<t> : azuretablebase<t>, iinitializer t : tableserviceentity     {          public azuretable()             : this(cloudconfiguration.getstorageaccount())         {         }          public azuretable(cloudstorageaccount account)             : this(account, null)         {         }          public azuretable(cloudstorageaccount account, string tablename)             : base(account, tablename)         {         } 

this remove repitition of gettable family of methods:

public static iazuretable<t> gettable<t>(string datastorevalue, string tablename) t : tableserviceentity     {          return new azuretable<t>(getstorageaccount(datastorevalue), tablename);     } 

you call this:

var table = gettable<sequence>("datastorename", "sequences"); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -