Is there a way for an attribute that has been applied to a method to know what method it was applied to at run time?
[AttributeUsage(AttributeTargets.Method)]
public class CustomAttribute : Attribute {}
public class Foo
{
[Custom]
public void Method() {}
}
Then I query the attribute at run time
var attribute = typeof(Foo)
.GetMethod("Method")
.GetCustomAttributes(false)
.OfType<CustomAttribute>()
.First();
Can "attribute" tell it was applied to the "Method" method on the "Foo" class?