I am currently writing a Lib to make use of a HttpWebRequest class and properties. After calling certain methods I will need my HttpWebRequest attribute of the class to be reconstructed, but not from scratch.
This is what I want to accomplish:
-
Backup the properties from the existing HttpWebRequest
System.Reflection.PropertyInfo[] properties = m_HttpWebRequest.GetType ().GetProperties ();
-
Re-instantiate the attribute, creating a new WebRequest
m_HttpWebRequest = (HttpWebRequest)WebRequest.Create(requestUrl);
-
Add the copied properties to the new instance. Which I am unable to do yet.
Any ideas of how to implement the third step?
Currently I can get the name of each Property by using:
properties[index].Name
But I can’t reference the value.
This should roughly get you there: