Dynamic Post Reflection
Posted by Ron Rechtman
Wednesday, January 27, 2010 3:59:31 PM
I had a problem with one of my clients that each time i turned around the data needed to be posted to someone new...
So I decided to create an configurable posting mechanism. A UI that you place the URL and some static data for the partner and a mapping section.
What I came up with is:
- The Admin UI has a DataList which the postback will build the XML as needed to be stored in the database.
- Some reflection code based off the XML that build the string to post to the 3rd party.
The hardest part was figuring out the reflection so the object with the data in it, lets call it Cutomer c, to get c.FirstName dynamically it is done by c.GetType().GetProperty("FirstName").GetValue(c, null).
Not too bad at the end.