AllServicesDiagnostic
using Castle.MicroKernel;
using System;
using System.Linq;
namespace Castle.Windsor.Diagnostics
{
public class AllServicesDiagnostic : IAllServicesDiagnostic, IDiagnostic<ILookup<Type, IHandler>>
{
private readonly IKernel kernel;
public AllServicesDiagnostic(IKernel kernel)
{
this.kernel = kernel;
}
public ILookup<Type, IHandler> Inspect()
{
return (from handler in kernel.GetAssignableHandlers(typeof(object))
from service in handler.ComponentModel.Services
select new {
handler,
service
}).ToLookup(g => g.service, g => g.handler);
}
}
}