title: How to check if method has an attribute
body: <p>I have an example class</p>
  
  <pre><code>public class MyClass{
  
      ActionResult Method1(){
          ....
      } 
  
      [Authorize]
      ActionResult Method2(){
         ....
      }
  
      [Authorize]    
      ActionResult Method3(int value){
         ....
      }
  
  }
  </code></pre>
  
  <p>Now what I want is to write a function returning true/false that can be executed like this</p>
  
  <pre><code>var controller = new MyClass();
  
  Assert.IsFalse(MethodHasAuthorizeAttribute(controller.Method1));
  Assert.IsTrue(MethodHasAuthorizeAttribute(controller.Method2));
  Assert.IsTrue(MethodHasAuthorizeAttribute(controller.Method3));
  </code></pre>
  
  <p>I got to the point where</p>
  
  <pre><code>public bool MethodHasAuthorizeAttribute(Func&lt;int, ActionResult&gt; function)
  {
      return function.Method.GetCustomAttributes(typeof(AuthorizeAttribute), false).Length &gt; 0;
  }
  </code></pre>
  
  <p>would work for Method3. Now how can I do that generic in a way that it'll take strings and classes as parameters as well?</p>