Skip to content

API Overview

Marcus Ackre Medina edited this page Sep 13, 2026 · 1 revision

API Overview

Namespace: MarcusMedinaPro.ClassEnumerator

Note: the NuGet package is MarcusMedina.Reflection.ClassEnumerator; the namespace has always stayed MarcusMedinaPro.ClassEnumerator, unchanged since the old MMPClassEnumerator package.

EnumerateClasses<T>

Generic static class. T is the interface or base class to search for.

GetClassesByInterface

IEnumerable<T> GetClassesByInterface(bool useCache = false, Assembly? assembly = null)

Returns instances of all non-abstract classes in the assembly that implement T (where T is an interface).

  • Results are sorted by type name.
  • Classes must have a public parameterless constructor.

GetClassesByInheritance

IEnumerable<T> GetClassesByInheritance(bool useCache = false, Assembly? assembly = null)

Returns instances of all non-abstract classes whose direct base class is T.

  • Results are sorted by type name.
  • Classes must have a public parameterless constructor.

ListClassesByInterface

IEnumerable<Type> ListClassesByInterface(bool useCache = false, Assembly? assembly = null)

Like GetClassesByInterface but returns Type objects instead of instances. Useful when you need to inspect types without instantiating them.

ListClassesByInheritance

IEnumerable<Type> ListClassesByInheritance(bool useCache = false, Assembly? assembly = null)

Like GetClassesByInheritance but returns Type objects.

ClearCache

void ClearCache()

Clears all cached results for every generic instantiation of EnumerateClasses<T>. Useful if assemblies are loaded dynamically at runtime and a previously cached scan is now stale.

Parameters

Parameter Default Description
useCache false Cache results per assembly — faster on repeated calls
assembly null Target assembly. Null = calling assembly

Performance

Without cache, reflection scans all types on every call. Enable useCache: true in hot paths or for plugins discovered at startup. Call ClearCache() if you load assemblies dynamically after the first scan.

Clone this wiki locally