I have a scenario where I need to know if a specific type can currently be resolved by a Windsor container. The wrinkle is that this type has dependencies. So I have a ProductRepository class that implements IRefDataRepository and depends on IProductDataProvider. I need to know if I can successfully resolve IRefDataRepository from the container.
I tried using IKernel.HasComponent(typeof(IRefDataRepository)) IKernel.GetAssignableHandlers(typeof(IRefDataRepository)) both of which return ProductRepository even there is no IProductDataProvider registered. (So IWindsorContainer.Resolve(typeof(IRefDataRepository)) will throw)
My current solution is to write an extension method that actually tries to resolve the type (via IWindsorContainer.Resolve(IRefDataRepository)), catches the exception, and returns true if the type resolves and false otherwise. But I'm wondering if there is a better way.