
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 0.50 KB | hits: 10 | expires: Never
Attribute on method doesn't work
[AttributeUsage(System.AttributeTargets.Method)]
public class RequireAuthorization : System.Attribute
{
private bool _protected = true;
public RequireAuthorization(bool protect)
{
_protected = protect;
}
}
public class MyClass(){
[RequireAuthorization(true)]
public bool method1(){
// some actions
}
}
MemberInfo memberInfo = typeof(MyClass).GetMethod("method1");
var attributes = memberInfo.GetCustomAttributes(false);