In a Castle Windsor scenario I want to check if my container has a certain service registered, and do basically
if (container.HasComponentFor<IMyService>()) {
// resolve service with container.Resolve<IMyService>()
// then do cool stuff
}
but of course, container.HasComponentFor<IMyService>()
doesn't exist. Is there an equivalent?
You can check if the MicroKernel has the component registered:
if (container.Kernel.HasComponent(typeof(IMyService)))
// resolve service with container.Resolve<IMyService>()
// then do cool stuff
}