Choose Method Based on Attribute?

  • Thread starter Thread starter localhost
  • Start date Start date
L

localhost

I have a method in a class with [MyAttribute("x")] on it, and the same
method with different overloads and [MyAttribute("y")] on it.

How can my calling class, via Reflection, pick [MyAttribute("y")]
over the first one?

Thanks.
 
localhost said:
I have a method in a class with [MyAttribute("x")] on it, and the same
method with different overloads and [MyAttribute("y")] on it.

How can my calling class, via Reflection, pick [MyAttribute("y")]
over the first one?

Use MemberInfo.GetCustomAttributes on each of the candidate methods,
and look at the values returned.
 
Back
Top