C# - Get value of property from an object dynamically
Posted on 2012-03-10
I have a class called "shipment" that contains a lot of properties, such as Address1, Address2, Address3, PostCode, OrderNumber etc etc etc. This object gets passed to a web service, it creates the orders, then it sends an email. However, I want to make the email dynamic. For instance: for customer A, I might want to show Address1 and Address2, Customer B might want to show OrderNumber and Post Code
What I want to do, is have a database table that is called, and then says which properties of the object need to go onto the email. I think I need to use reflection, but I don't really understand it
So, in the db table will be a value of shipment.Address1 and shipment.Address2 which will be pulled out as strings, that then needs converting to take the value of the actual shipment.Address1 and 2
Does this make sense ? Hopefully have explained myself ok !
Thanks in advance