Skip to content

Instantly share code, notes, and snippets.

@feanz
Created December 11, 2013 13:09
Show Gist options
  • Save feanz/7910136 to your computer and use it in GitHub Desktop.
Save feanz/7910136 to your computer and use it in GitHub Desktop.
MethodInfoExtensions
public static class MethodInfoExtensions
{
/// <summary>
/// Will return the name of the action specified in the ActionNameAttribute for a method if it has an ActionNameAttribute.
/// Will return the name of the method otherwise.
/// </summary>
/// <param name="method"></param>
/// <returns></returns>
public static string ActionName(this MethodInfo method)
{
if (method.IsDecoratedWith<ActionNameAttribute>()) return method.GetAttribute<ActionNameAttribute>().Name;
return method.Name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment