Вот пример для mscorlib.dll.Он находит все классы, которые имеют свойство с именем «Capacity».
Assembly asm = Assembly.Load("mscorlib.dll");
foreach (Type type in asm.GetTypes())
{
foreach (MemberInfo mem in type.GetMembers())
{
if ((mem.MemberType == MemberTypes.Property) && (mem.Name == "Capacity"))
Console.WriteLine(type);
}
}
Или, используя LINQ:
var asm = Assembly.Load("mscorlib.dll");
foreach (var type in from type in asm.GetTypes()
from mem in type.GetMembers()
where (mem.MemberType == MemberTypes.Property) &&
(mem.Name == "Capacity")
select type)
Console.WriteLine(type);
Вот вывод:
System.Text.StringBuilder
System.Collections.CollectionBase
System.Collections.ArrayList
System.Collections.ArrayList+IListWrapper
System.Collections.ArrayList+SyncArrayList
System.Collections.ArrayList+FixedSizeArrayList
System.Collections.ArrayList+ReadOnlyArrayList
System.Collections.ArrayList+Range
System.Collections.SortedList
System.Collections.SortedList+SyncSortedList
System.Collections.Generic.List`1[T]
System.IO.MemoryStream
System.IO.UnmanagedMemoryStream
System.IO.PinnedBufferMemoryStream
System.IO.UnmanagedMemoryAccessor
System.IO.UnmanagedMemoryStreamWrapper