12

Autofac コンテナーがあり、登録されているすべてのサービスの種類 (実装の種類ではなく、登録されている種類) を取得できるようにしたいと考えています。

からこの情報を取得するにはどうすればよいIComponentContextですか?

4

2 に答える 2

20

これを使用できます:

var services =
    context.ComponentRegistry.Registrations.SelectMany(x => x.Services)
           .OfType<IServiceWithType>()
           .Select(x => x.ServiceType); 
于 2013-03-19T12:27:07.357 に答える