Get a list of all registered objects implementing a certain interface

Just tried this, works and does not depend on lifetime context:

Enumerate types using Activator instead

var types = con.ComponentRegistry.Registrations
     .Where(r => typeof(ISomeInterface).IsAssignableFrom(r.Activator.LimitType))
     .Select(r => r.Activator.LimitType);

Then to resolve:

IEnumerable<ISomeInterface> lst = types.Select(t => con.Resolve(t) as ISomeInterface);

Leave a Comment