Configuration - List of key/values without using custom section
-
I'd like to include a list of values in my app.config file that has no specific length. I don't want to use "Setting 1" "Setting 2" etc. for obvious reasons. I could define a type that wraps a List for example and use this as the type for a custom section... However this seems a little over the top. I am also dealing with a distributed system that has various components, and so I would like to avoid having to make that type available to in all of them. Does anybody know a lightweight way of achieving this that is already part of the framework / System.Configuration namespace? Thanks
-
I'd like to include a list of values in my app.config file that has no specific length. I don't want to use "Setting 1" "Setting 2" etc. for obvious reasons. I could define a type that wraps a List for example and use this as the type for a custom section... However this seems a little over the top. I am also dealing with a distributed system that has various components, and so I would like to avoid having to make that type available to in all of them. Does anybody know a lightweight way of achieving this that is already part of the framework / System.Configuration namespace? Thanks
I use a settings datatable based on an XML file, easy to maintain, easy to manage and you have complete control of it.
Never underestimate the power of human stupidity RAH
-
I use a settings datatable based on an XML file, easy to maintain, easy to manage and you have complete control of it.
Never underestimate the power of human stupidity RAH
Hi, Thanks for the suggestion. Unfortuantely using a database is not really viable for this particular problem, as some of the components involved are deployed at customers' premises. I don't want to add the complexity of deploying a database engine etc. Thanks, Rob.
-
I use a settings datatable based on an XML file, easy to maintain, easy to manage and you have complete control of it.
Never underestimate the power of human stupidity RAH
Ahhh... I've just re-read your post. Properly this time :-O Do you think it is possible to use a datatable as a Type for a custom config section? The solution is quite committed to using app.config and System.Configuration. I wouldn't want to have to have a second xml file containing the serialised datatable - so I'd need to get it into app.config somehow... Thanks again, Rob.
-
I'd like to include a list of values in my app.config file that has no specific length. I don't want to use "Setting 1" "Setting 2" etc. for obvious reasons. I could define a type that wraps a List for example and use this as the type for a custom section... However this seems a little over the top. I am also dealing with a distributed system that has various components, and so I would like to avoid having to make that type available to in all of them. Does anybody know a lightweight way of achieving this that is already part of the framework / System.Configuration namespace? Thanks
LINQ to XML would work, and you could write/read your own file without worrying about messing up or dealing with multiple app.config files. I'd probably create a class lib project that you can use in multiple assemblies. Shouldn't be too hard to come up with something usable and flexible.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
I'd like to include a list of values in my app.config file that has no specific length. I don't want to use "Setting 1" "Setting 2" etc. for obvious reasons. I could define a type that wraps a List for example and use this as the type for a custom section... However this seems a little over the top. I am also dealing with a distributed system that has various components, and so I would like to avoid having to make that type available to in all of them. Does anybody know a lightweight way of achieving this that is already part of the framework / System.Configuration namespace? Thanks
Thanks for all your suggestions. I have decided on the following: Declare a section in app.config ilke this:
The section then utilised like this: a1 b1 c1 and then accessed in code like this: System.Configuration.ClientSettingsSection sect = (System.Configuration.ClientSettingsSection)System.Configuration.ConfigurationManager.GetSection("SecondaryIdentifiersSect"); foreach (System.Configuration.SettingElement e in sect.Settings) { System.Diagnostics.Debug.WriteLine(e.Name); System.Diagnostics.Debug.WriteLine(e.Value.ValueXml.InnerText); }