How to inject Service interface in custom attribute

Feb 12, 2015 at 9:59 PM
Edited Feb 13, 2015 at 1:48 AM

I've writing a custom authorization attribute. Just want to find out how I can instantiate the service interface here?

Many thanks.
May 12, 2015 at 6:09 PM
If you can't inject you can use ServiceLocator.Current.GetInstance<ICustomerRepository>() you will need to make sure ServiceLocator adapter is configured for you DI/IoC framework you are using, the sample uses Unity and this is already configured.
Marked as answer by lelong37 on 5/12/2015 at 10:09 AM