Код: Выделить всё
public class Test1
{
[SubTests]
List SubTests { get; set; } = [];
public void Run()
{
foreach(var subtest in SubTests)
{
// ...
}
}
public class SubTest1 : ISubTest { }
}
public class Test2
{
[SubTests]
List SubTests { get; set; } = [];
public void Run()
{
foreach(var subtest in SubTests)
{
// ...
}
}
public class SubTest2 : ISubTest { }
}
public interface ISubTest { }
Я попытался получить список таким:
Код: Выделить всё
foreach (var property in type.GetProperties())
{
if (property.GetCustomAttribute() != null)
{
var subTests = (IList)property.GetValue(valueSource);
return new BindingList(subTests)
}
}
Есть способ сделать то, что я пытаюсь сделать?
Подробнее здесь: https://stackoverflow.com/questions/794 ... reflection
Мобильная версия