private List <ObjectGridPropertyDef> GetProperties(Type type) { var res = new List <ObjectGridPropertyDef>(); foreach (var desc in type.GetProperties()) { bool show = false; int weight = 0; foreach (ShowInGridAttribute attr in desc.GetCustomAttributes(typeof(ShowInGridAttribute), true)) { show = true; weight = attr.Order; } if (!show) { continue; } string dname = desc.Name; foreach (DatAdmin.DisplayNameAttribute attr in desc.GetCustomAttributes(typeof(DatAdmin.DisplayNameAttribute), true)) { dname = attr.DisplayName; } m_colWeights[dname] = weight; var od = new ObjectGridPropertyDef(); od.BaseType = type; od.DisplayName = dname; od.Property = desc; res.Add(od); } return(res); }
public ObjectGridOverview(IList data) { m_data = new List <object>(data.Count); foreach (var obj in data) { m_data.Add(obj); var type = obj.GetType(); if (m_types.ContainsKey(type)) { continue; } m_types[type] = GetProperties(type); } var cols = new HashSetEx <string>(); foreach (var lst in m_types.Values) { foreach (var def in lst) { cols.Add(def.DisplayName); } } m_columns = new List <string>(cols); m_columns.Sort(CompareCols); foreach (var tp in m_types.Keys) { m_colDefs[tp] = new List <ObjectGridPropertyDef>(); foreach (string col in m_columns) { ObjectGridPropertyDef def = null; foreach (var d in m_types[tp]) { if (d.DisplayName == col) { def = d; break; } } m_colDefs[tp].Add(def); } } }