ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

GetAttribute

get custom attribute helper

Source

public static T GetAttribute<T>(this PropertyInfo pi) where T : Attribute
{
 return   pi.GetCustomAttributes(typeof (T), false).FirstOrDefault() as T;
}

Example

var attribute = PropertyInfoInstance.GetAttribute<XmlSerializationAttribute>();

Author: UnstableMutex

Submitted on: 23 okt 2014

Language: C#

Type: PropertyInfo

Views: 4138