aI am trying to use reflection to retrieve the properties of a Microsoft.Office.Interop.Excel.Series object. The code executes with no errors, but only a partial listing of the properties is returned (when compared to the properties listed in the Object Browser for the ...Series object). When looking at a runtime watch listing of the ...Series object, the full listing is displayed under "Dynamic View". Documentation that I have found states that these are Dynamic Members and are not available for editing. Is it possible to use reflection to access the Dynamic Members ?
I am using Windows 8.1, VS 2013 on Office 2013 Professional Plus. I have a strong VBA Background, ~1 year C# experience.
public void LoadProperties(dynamic SourceObject, dynamic TargetObject)
{
Type sourcetype = SourceObject.GetType();
Type targettype = TargetObject.GetType();
if(sourcetype.Equals(targettype))
{
PropertyInfo[] properties = typeof(Microsoft.Office.Interop.Excel.Series).GetProperties();
foreach (PropertyInfo property in properties)
{
object propertyvalue = property.GetValue(SourceObject);
sourcetype.GetProperty(property.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static |
BindingFlags.NonPublic ).SetValue(TargetObject,propertyvalue);
}
}
}