using System;
|
using System.Collections.Generic;
|
using System.Reflection;
|
|
namespace HMI.Util
|
{
|
class PropertyHelper
|
{
|
public static List<PropertyInfo> GetAtterProperty<T, A>(out List<A> attrs) where A : Attribute
|
{
|
var result = new List<PropertyInfo>();
|
attrs = new List<A>();
|
|
var type = typeof(T);
|
var attrType = typeof(A);
|
|
PropertyInfo[] properties = type.GetProperties();
|
|
foreach (var prop in properties)
|
{
|
if (Attribute.IsDefined(prop, attrType))
|
{
|
result.Add(prop);
|
attrs.Add((A)Attribute.GetCustomAttribute(prop, attrType));
|
}
|
}
|
return result;
|
}
|
}
|
}
|