aリフレクションを使用して、Microsoft.Office.Interop.Excel.Series オブジェクトのプロパティを取得しようとしています。コードはエラーなしで実行されますが、プロパティの部分的なリストのみが返されます (オブジェクト ブラウザにリストされている ...Series オブジェクトのプロパティと比較した場合)。...Series オブジェクトのランタイム ウォッチ リストを見ると、完全なリストが [Dynamic View] の下に表示されます。私が見つけたドキュメントには、これらは動的メンバーであり、編集できないと記載されています。リフレクションを使用して動的メンバーにアクセスすることは可能ですか?
Office 2013 Professional Plus で Windows 8.1、VS 2013 を使用しています。私は強力な VBA のバックグラウンドを持ち、約 1 年間の C# の経験があります。
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);
}
}
}