Microsoft.Practices.ServiceLocation and TryGetInstance
- by Feryt
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.