Object Extension Methods

IEnumerable<T> Attributes<T>()
Gets a collection of attributes(of a certain type) found on a type.
[MyCustom]
public class MyCustomClass
{ 
    
}

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class MyCustomAttribute : Attribute
{ 
    
}

// given the setup above and used in some method like:
MyCustomClass instance = new MyCustomClass();
var attributes = instance.Attributes<MyCustomAttribute>();

Last edited Feb 19, 2010 at 1:55 PM by jole, version 1

Comments

No comments yet.