0
こんにちは私は他の複合型の中にある複合型の拡張可能なコレクションを持っていたいと思います。任意のコレクション(複合グリッド)の複合型内で消費可能な複合型
private static void SetExpandableAttrForType(Type type)
{
var props = type.GetProperties();
foreach (var prop in props.Where(x =>!x.PropertyType.IsSimpleType()&& x.CanWrite))
{
SetExpandableAttrForType(prop.PropertyType);
}
TypeDescriptor.AddAttributes(type, new TypeConverterAttribute(typeof (ExpandableObjectConverter)));
}
、その後
SetExpandableAttrForType(arrayInstance.GetType().GetElementType());
テストモデル::
public class Class1
{
public Class2 Class2Inclass1 { get; set; }
public Class2[] Class2Array { get; set; }
}
public class Class2
{
public Class3 Class3Inclass2 { get; set; }
public string Class2String { get; set; }
public string Class2String2 { get; set; }
}
public class Class3
{
public Class4 Class4Inclass3 { get; set; }
public string Class3String { get; set; }
public int Class3Int { get; set; }
}
public class Class4
{
public int Class4Int { get; set; }
public DateTime Class4Datetime { get; set; }
}
それはタイプのためではなく、型のコレクションのために正常に動作します私はこれをしたいどのように 。