リフレクションを使用してByte[]を取得しようとしています。残念ながら、結果は常にNULLになります。プロパティはデータでいっぱいです。これが私のコードスニペットです。
public static void SaveFile(BusinessObject document)
{
Type boType = document.GetType();
PropertyInfo[] propertyInfo = boType.GetProperties();
Object obj = Activator.CreateInstance(boType);
foreach (PropertyInfo item in propertyInfo)
{
Type xy = item.PropertyType;
if (String.Equals(item.Name, "Content") && (item.PropertyType == typeof(Byte[])))
{
Byte[] content = item.GetValue(obj, null) as Byte[];
}
}
return true;
}
動作するコードは次のとおりです。
public static void SaveFile(BusinessObject document)
{
Type boType = document.GetType();
PropertyInfo[] propertyInfo = boType.GetProperties();
foreach (PropertyInfo item in propertyInfo)
{
if (String.Equals(item.Name, "Content") && (item.PropertyType == typeof(Byte[])))
{
Byte[] content = item.GetValue(document, null) as Byte[];
}
}
}