Check for Windsor Container Component Instance
Posted
by jeffn825
on Stack Overflow
See other posts from Stack Overflow
or by jeffn825
Published on 2010-06-09T19:21:15Z
Indexed on
2010/06/10
22:33 UTC
Read the original article
Hit count: 240
castle-windsor
|registration
How can I use my Windsor container to check if an instance (not just a component) has been registered?
ie. container.ContainsInstance(typeof(MyType))
[EDIT]
Another way of writing this might be
Kernel.GetAssignableHandlers(typeof(object))
.Where(handler => handler.Service == typeof(MyType) || handler.ComponentModel.Implementation == typeof(MyType))
.Any(handler => handler.***Instance*** != null)
Note that the property Instance doesn't exist in the API.
Thanks.
© Stack Overflow or respective owner