The Last Configuration Handler I'll Ever Need

Here. From Craig Andera: I'm sure someone, somewhere has already written this, but I figured it out on my own today, and it's just too cool not to share. Basically, it's a bit of code that lets me store objects in my application or web configuration file, and all I have to do is write the type that holds the values.


Comment Feed 6 comments on this post

Michael Bouck:


Very elegant -- I like it! This is one of those things where you slap yourself on the head and say "of course!"

Saturday, Feb 22, 2003, 12:24 PM


Craig Andera:


Thanks! I thought so too. That's why I said, "I'm sure someone must have written this already..." :)

Saturday, Feb 22, 2003, 6:08 PM


Chris Sells:


That's cool, Craig. Does it come with a utility that tells you the format of the XML to put into the .config for your custom type?

Monday, Feb 24, 2003, 4:14 PM


Craig Andera:


Geez, Chris, what do you want from me? :)

I'll see what I can whip up.

Wednesday, Feb 26, 2003, 10:33 PM


Craig Andera:


I didn't have time to explore what it would take to spit out example XML given an arbitrary type, so I thought of a cheesy way to do it. It's based on the fact that ASMX web services use the same XML serialization engine that I do.

* Write the type you want to store.
* Write a simple ASMX web service that has one method that has a single input parameter of that type.
* Navigate to the ASMX-generated HTML page for the web service, and click on the link for that operation.
* Go look in the sample SOAP message - you should see your type expressed as XML.
* Cut and paste into your config file, adding the "type" attribute.

How's that, Chris?

Thursday, Feb 27, 2003, 9:57 AM


Marlo:


How do you extend this solution to incorporate repetitive items?
 i.e
    (Foo name=”A”)1.234(/Foo)
    (Foo name=”B”)5.678(/Foo)

Monday, Mar 31, 2003, 5:34 PM





comment on this post

HTML tags will be escaped.

Powered By ASP.NET

Hosted by SecureWebs

Microsoft

Mensa

IEEE


moving companies
addiction treatment
sunglasses
Kratom
How To Lose Weight Fast
cocktail dresses
Credit Card Balance Transfer
Add URL
Stock Trading
Health Insurance Quotes
Promotional Merchandise
Jet Privé
loans for bad credit