Код: Выделить всё
var collectionInterfaceType = GetTypeHierarchy(type)
.SelectMany(t => t.Interfaces)
.Select(iface => iface.InterfaceType)
.OfType()
.FirstOrDefault(interfaceType =>
interfaceType.ElementType.FullName is "System.Collections.Generic.ICollection`1" or "System.Collections.Generic.IReadOnlyCollection`1");
if (collectionInterfaceType != null)
{
var itemType = collectionInterfaceType.GenericArguments[0];
// Do something with itemType
}
Код: Выделить всё
public class CustomCollection : List { }
Подробнее здесь: https://stackoverflow.com/questions/798 ... with-cecil
Мобильная версия