c# - Simplifying class structure -


i have set configuration system grab configuration mysql database. , have got working, realize value cache, have use long messy code.

cachelayer.instance.caches["app_config"].current.emailalertinterval 

i remove current, haven't managed figure out if it's possible have class directly. @ moment implementation looks this.

public t current {         {         if (_current == null)         {             reloadconfiguration();         }          return _current;     } } 

but this:

cachelayer.instance.caches["app_config"].emailalertinterval 

i looking @ this, works indexers.

public t this[t key] 

edit: add more context add more code.

this cachelayer. allows me store multiple configurations. may have 1 example general app config, can grab array of emails used.

public dictionary<string,igenericcache<dynamic>> caches {         {         return _caches;     } }  public void addcache(string config) {     _caches.add(config,new genericcache<dynamic>(config)); } 

inside genericcache load configuration using json string stored in mysql db.

_current = jsonconvert.deserializeobject<t>(db.dbfetchconfig(config)); 

the reason genericconfig t , not dynamic because want able make custom implmentation outside of cachelayer, 1 not use dynamic.

another example on how want used.

list<string> emaillist = cachelayer.instance.caches["emaillist"].current; 

this in fact grab json array mysql containing list of emails.

any ideas?

add new property

public int emailalertinterval {     { return current.emailalertinterval; } } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -