Is there a way to have extension method on the method? Example for this would be method that takes some user object as parameter and you need to do security check if that user can use that method at the very beginning of the method. Can the method have extension method like “check can this user use me” and return bool.
Thanks.
You can use Aspect Oriented Programming (AOP) to implement cross-cutting security checks in your code.
In .NET you have a choice of several AOP frameworks, for example:
In particular the PostSharp documentation has some nice examples on how to implement security using AOP.