В общем, такой поиск может выглядеть так:
public static class ExtensionMethods
{
private static void GetAllInstancesRecursive(IApplicationContext context,
Type serviceType,
ref ICollection<object> result)
{
if (context == null) return;
foreach (object o in context.GetObjectsOfType(serviceType).Values)
{
result.Add(o);
}
GetAllInstancesRecursive(context.ParentContext, serviceType, ref result);
}
public static IEnumerable<object> GetObjectsOfTypeRecursive(this IApplicationContext context,
Type serviceType)
{
ICollection<object> result = new Collection<object>();
GetAllInstancesRecursive(context, serviceType, ref result);
return result;
}
}