Click here to Skip to main content
11,482,039 members (63,571 online)
Click here to Skip to main content
Articles » Languages » C# » General » Alternatives
Alternatives (2)

Tagged as

Get CustomAttributes the easy way....

, 16 Apr 2010 CPOL 7.4K 2
A few extension methods to help out.....// Project: Salient.Reflection// http://salient.codeplex.comusing System;using System.Collections.Generic;using System.Linq;using System.Reflection;public static class AttributeHelpers{ /// /// Returns first...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

15 Apr 2010
Wouter Ballet
I have a similar set of extension methods, but instead of MemberInfo, I used ICustomAttributeProvider, which is a more general approach as MemberInfo implements this interface. This would make the extensions usable on the types Assembly and Module to name just a few...Regards,Wouter
15 Apr 2010
tonyt
How about typing the 'this' parameter as ICustomAttributeProvider ?Also, ToList(...).Where(...) is bad Linq usage, becauseToList() triggers enumeration of the sequence. Try Where(...).ToList() instead.And the ToList() in 'ToList().FirstOrDefault(...)' is entirely pointless.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sky Sanders
Software Developer (Senior) Salient Solutions
United States United States
My name is Sky Sanders and I am an end-to-end, front-to-back software solutions architect with more than 20 years experience in IT infrastructure and software development, the last 10 years being focused primarily on the Microsoft .NET platform.

My motto is 'I solve problems.' and I am currently available for hire.

I can be contacted at sky.sanders@gmail.com

| | Privacy | Terms of Use | Mobile
Web02 | 2.8.150520.1 | Last Updated 16 Apr 2010
Article Copyright 2010 by Sky Sanders
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid