c# - Website Architecture - Control/Object Loading Based on Config? -


i building site need change in markets. example, in uk market, signup form needs perform address validation (already have working), , on belgium site, need verify person web service (already have working). otherwise, signup functionality same. have these 2 sites working independently, we'd merge them single codebase can support either option based on config.

my initial thought use configuration value "this uk site" or "this belgium site" , display pages based on setting.

ideas:

  • dependency injection load controls dynamically based on config
  • factory pattern use reflection/activator , load dynamically based on config
  • config transforms load different user controls setting tagname/tagprefix
  • other?

does have first thoughts on recommendations on can find inspiration type of design?

i recommend keep simple , minimal possible.

simply create ipersonvalidator has .validate(persondetails) method , returns array of errors.

edit:

on config side, create custom config section of following structure:

<domainspecificsettings>  <key name="validator">   <value domain="www.yoursite.co.uk" value="firstvalidator" />   <value domain="www.yoursite.de" value="secondsvalidator" />  </key> </domainspecificsettings>  

one more thing - don't need use activator. have singleton validators store holds single instance each validator type , knows how find correct validator according database config setting of viewd market:

validatorsstore.getvalidator(string configvalue).validate(persondetails). 

the design in case may become overkill such simple task. approach first make work enough, , check if need make more robust. chances won't.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -