views:

53

answers:

1

Due to a requirement in my current project, I have to build a configuration manager to handle configurations that merge local config info with database one. Custom configuration doesn't fit my needs, problem is that I don't know what's the type before loading certain information, for example:

Loading database information I will able to know what's myhandler's type. Not previously. So I thought to write my own handler but I can't let set blank as type for sections, in fact .net requires to know what's the type to match myhandler nodes. I'm thinking on building a different parser to read XML nodes but I would prefer to match this structure. I've not found any information to do that yet, is there any way? Can I extend or hook up something into the framework to be capable of loading on-the-fly types and validate nodes?

Thanks in advance.

A: 

I'm not sure I fully understand the question, but I think what you're asking is if you read in a list of configuration values without knowing their type, probably strings, can you determine what type of objects you need to construct?

I'm going to assume your database configuration has a table of values, hopefully key/value pairs, like:

Item1 = 15
Item2 = False
Item3 = xyz

You want a generic read method that reads in those from a config file and will convert Item1 to an Integer, Item2 to a Boolean, and Item3 to a String.

All of the base types have a TryParse, so you can read in the string from the configuration file and if the key = Item1 then Integer.TryParse(value, someInt).

I'm not sure that addresses your question, I'm having a hard time following the wording.

Jacob Ewald
Thanks for answering, to keep it simple; I want to add a section to a section group without adding a type, because the type is unknown at the time of design. Something happened and I don't see part of the code that I wrote.section name="mycode" type="?" I don't know the type until I load some information from the database.
Maximiliano Rios