Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugger is not entering custom attribute class

This is a C# WPF application for a desktop. I've created a custom attribute class but in debug it never goes in there. Do I need to add something else to this class?

[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class Authentication : Attribute, IPrincipal
{
    public Authentication(string id)
    {
        throw new NotImplementedException();
    }

    public IIdentity Identity { get; private set; }

    public bool IsInRole(string role)
    {
        throw new NotImplementedException();
    }

}

And the method is:

    [Authentication(SecurityConstants.DataEntrySupervisor)]
    [Authentication(SecurityConstants.DataVerificationClerk)]
    public void Submit(EventObject eventObject)
    {//////////}
like image 930
NNassar Avatar asked Nov 10 '22 10:11

NNassar


1 Answers

An attribute is not called by the runtime in any way. It probably does not even get instanciated until you poke around with reflection.

You can look at SecurityAttribute if you want to do code security with attributes.

like image 195
nvoigt Avatar answered Nov 15 '22 08:11

nvoigt