mercredi 1 mars 2017

Get action name as string for Attribute-parameter

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)





Aucun commentaire:

Enregistrer un commentaire