"Adding Reflection-Based Polymorphism, Second Part"

public static class ComponentExtensions {
    private static readonly Dictionary<string, Dictionary<Type, MethodInfo>> overrides = new Dictionary<string, Dictionary<Type, MethodInfo>>();
     
    internal static void PopulateOverrideTable() {
        var allLoadedTypes = AppDomain.CurrentDomain.GetAssemblies()
            .SelectMany(ass => ass.GetReferencedAssemblies().Select(Assembly.Load).Concat(new[] { ass }))
            .Distinct()
            .SelectMany(ass => ass.GetTypes());
 
        var allComponentExtensions = typeof(ComponentExtensions).GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)
              .Where(mi => mi.GetCustomAttributes(typeof(ExtensionAttribute), false).Length > 0);
 
        foreach (Type t in allLoadedTypes) {
            foreach (MethodInfo extMethod in allComponentExtensions) {
                string callerMemberName = extMethod.Name;
                var matchingOverride = t.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                    .FirstOrDefault(mi => mi.Name == callerMemberName);
                if (matchingOverride != null) {
                    if (!overrides.ContainsKey(callerMemberName)) overrides[callerMemberName] = new Dictionary<Type, MethodInfo>();
                    overrides[callerMemberName][t] = matchingOverride;
                }
            }
        }
    }
}


Code snippet taken from "Simulating Multiple Inheritance In C#".