I have an Autofac container, and I would like to receive all registered types of services (not implementation types, but types that they registered as).
How can I get this information from IComponentContext ?
IComponentContext
You can use this:
var services = context.ComponentRegistry.Registrations.SelectMany(x => x.Services) .OfType<IServiceWithType>() .Select(x => x.ServiceType);
How i resolved it
var alldb = (from r in MasterDataFactory.Container.ComponentRegistry.Registrations let s = r.Services.Where(i => i is KeyedService).Select(i => i as KeyedService).FirstOrDefault() where s!=null && s.ServiceType==typeof(ISomeInterface) select s).ToList();