Microsoft.Practices.ServiceLocation and TryGetInstance

Posted by Feryt on Stack Overflow See other posts from Stack Overflow or by Feryt
Published on 2010-04-12T08:23:44Z Indexed on 2010/04/12 9:03 UTC
Read the original article Hit count: 529

Filed under:
|

Why Microsoft.Practices.ServiceLocation.IServiceLocator does not offer TryGetInstance()?

I need to get generic validator instance ServiceLocator.Current.GetInstance<IEntityValidator<TEntity>>() but not all Entities has registered validator.

The only solution i found is to use try{}catch{} block, but i dont like this approach.

© Stack Overflow or respective owner

Related posts about ioc-container

Related posts about .NET