public void DataBinding(Tuple<string,BindingType> BindingMember) { dba = me.GetCustomAttributes(typeof(DataBindingAttribute), true).FirstOrDefault() as DataBindingAttribute; if(dba != null) { dba.TableName = string.IsNullOrEmpty(dba.TableName) ? me.Name : dba.TableName; MemberInfo mi = null; switch(BindingMember.Item2) { case BindingType.Method: mi = me.GetMethod(BindingMember.Item1); break; default: mi = me.GetProperty(BindingMember.Item1); break; } if(mi != null) { OrderAttribute oa = mi.GetCustomAttributes(typeof(OrderAttribute), true).FirstOrDefault() as OrderAttribute; if(oa!=null) { List<Tuple<MemberInfo, OrderAttribute>> memberList = new List<Tuple<MemberInfo, OrderAttribute>>() { new Tuple<MemberInfo, OrderAttribute>(mi, oa) }; if (IsUsingSampleData) { sampleDataBinding(memberList); } else { tableDataBinding(memberList); } } } } }
public void DataBinding() { dba = me.GetCustomAttributes(typeof(DataBindingAttribute), true).FirstOrDefault() as DataBindingAttribute; if (dba != null) { dba.TableName = string.IsNullOrEmpty(dba.TableName) ? me.Name : dba.TableName; if (TypeCounts.ContainsKey(me)) { TypeCounts[me] += 1; } else { TypeCounts.Add(me, 0); } List<Tuple<MemberInfo, OrderAttribute>> reflectionMembers = null; IEnumerable<MemberInfo> members = null; switch (dba.SettingMode) { case SettingType.PropertyOnly: members = me.GetProperties(); break; case SettingType.MethodOnly: members = me.GetMethods(); break; default: members = me.GetMembers(); break; } reflectionMembers = members .Where(m => m.GetCustomAttributes(typeof(OrderAttribute), true).FirstOrDefault() != null) .Select(m => { return new Tuple<MemberInfo, OrderAttribute>(m, m.GetCustomAttributes(typeof(OrderAttribute), true).FirstOrDefault() as OrderAttribute); }).OrderBy(m=>m.Item2.Order).ToList(); if (IsUsingSampleData) { sampleDataBinding(reflectionMembers); } else { tableDataBinding(reflectionMembers); } } }