How to get all registered service types in Autofac
autofac, c#
Solution
You can use this:
var services =
context.ComponentRegistry.Registrations.SelectMany(x => x.Services)
.OfType<IServiceWithType>()
.Select(x => x.ServiceType);
Problem
I have an Autofac container and I would like to be able to retrieve all the registered service types (not the implementation types, but the types they are registered as). How can I get this information from an `IComponentContext`?