code_junkie

Testing if a Type has been registered in Unity

Nov 13th, 2011
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. public static class UnityContainerExtensions
  2. {
  3. public static bool IsRegistered<T>(this IUnityContainer container)
  4. {
  5. try
  6. {
  7. container.Resolve<T>();
  8. return true;
  9. }
  10. catch
  11. {
  12. return false;
  13. }
  14. }
  15. }
Add Comment
Please, Sign In to add comment