I want to apply an attribute which accepts a delegate as an argument, but I can't find the syntax to do it.
For example, to pass a class, you have to use typeof:
[SomeAttribute(typeof(SomeClass))]
What is the syntax for a delegate (I am trying to pass a static method)?
[SomeAttribute(??? SomeStaticMethod ???]
This is beyond the capacity of the Meta Data.
You could pass the method as a string and also specify the class if you just want to call a static method..
[SomeAttribute(typeof(SomeClass), @"SomeStaticMethod")]
Naturally you would have to invoke it through reflection, but since you are looking up the custom attributes anyway this probably isn't a big deviation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With