Last active
August 29, 2015 14:03
-
-
Save ianwaldrop/c498e6202780ca2b3fda to your computer and use it in GitHub Desktop.
Get Properties with Attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var props = t.GetProperties().Where( | |
prop => Attribute.IsDefined(prop, typeof(T))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/2281972/how-to-get-a-list-of-properties-with-a-given-attribute
This avoids having to materialize any attribute instances (i.e. it is cheaper than GetCustomAttributes.