Is there a way to get the decorated class name from inside an attribute?

15 Views Asked by At

So, I have perhaps a strange case that I need to solve this way.

[MyAttribute]
public class SomeUser
{

}

The challenge here is, I need to get the name of the decorated class ('SomeUser') inside the code of MyAttribute

Is there a way to do this? Like this example code:

public class MyAttributeAttribute: Attribute
{
    public MyAttributeAttribute()
    {

       //I'M LOOKING FOR SOMETHING LIKE THIS
       //var decoratedClass = this.GetType().GetDecoratedClass().Name;

    }
}

Unfortunatelly I need to identify the class name within the attribute, I know how to do this from outside, like "give me the classes with the attribute" but this case will not work for me.

Thanks

0

There are 0 best solutions below