I have some Action Attributes that allow parameters. This is how it looks like:
[DeleteActionCache(Action="GetTerms")]
public ActionResult AddTerm(string term){ }
public ActionResult GetTerms() {}
Now I want to get rid of the magic string "GetTerms" in my Attribute. So I would prefer something like: (Pseudocode, not working)
[DeleteActionCache(Action=this.GetTerms().GetType().Name)]
Having an additional Property inside my attribute-class and doing "Method2String"-Conversions inside my that class would be ok with me if this is needed to achieve what I want.
Info: I am not looking for a way the get the current method name (MethodBase.GetCurrentMethod)
nameof
could help here:
[DeleteActionCache(Action=nameof(GetTerms))]
Depending on the use of the property, you might be better of handling this at the place the attribute is read from the member, but in this case it seems hard since there isn't a fixed relationship between the action and the property.
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