public static string GetName <T>(this PropertyInfo property) where T : NameAttribute { FIDAttribute fid = property.GetCustomAttribute <FIDAttribute>(); return(fid.Name); //return property.Name; }
//public static List<T> FindAllControls<T>(this Control control) where T : class, IView; //public static T FindParentControl<T>(this Control owner) where T : class; //public static TViewModel FindViewModel<TViewModel>(this IViewModel viewModel) where TViewModel : IViewModel; //public static T GetAttri<T>(this EntityBase instance) where T : NameAttribute; public static string[] GetFIDList <T>(this object obj) where T : EntityRealBase { Type type = typeof(T); PropertyInfo[] Properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public); IEnumerable <PropertyInfo> a = Properties.Where(prop => Attribute.IsDefined(prop, typeof(FIDAttribute))); string[] result = new string[a.Count()]; //Console.WriteLine("Count: {0} : ", a.Count()); int i = 0; foreach (var el in a) { FIDAttribute fid = el.GetCustomAttribute <FIDAttribute>(); //Console.WriteLine("FID.Name: {0}", fid.Name); result[i++] = fid.Name; } return(result); }