Strategy for Runtime Configuration Values across Uses

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Let's say I create a class that I want to use in lots of different contexts
(e.g. as a .CS file put in the CODE folder in an ASP.NET2 application, in a
WindowsForms application, in a Console application). And let's say that I
want to be able to store certain configuration information externally. My
question is, short of just creating my own XML settings file that I read in
the class, is there a mrecommended way of storing and accessing this
information across all of these uses?

See, in a WindowsForms application, I can use a Resource, in an ASP.NET
application, I can pull app data out of Web.Config AppSettings, etc. But is
there a unified approach I can take instead?

Alex
 
You can create your own configuration sections in the .config file of the
hosting application, ASP.NET or otherwise. If you're using v2.0 then check
out the ConfigurationSection base class, as this is what you'll need to derive
from for your custom settings. You'd then use ConfigurationManager.GetConfig()
to read your custom config data as represented by your custom class.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top