/// <summary> /// Рекурсивный перебор всех элементов дерева. /// </summary> public void CreateInitData(PropertyInfoExs infos, TableMemberInfo info, ref int recordCount, int level) { if (level < LevelMax) { foreach (PropertyInfoEx prInfo in infos) { if (!(prInfo.IsXPCollection && prInfo.Parent != null && prInfo.Parent.IsXPBaseObject)) { TableMemberInfo tmInfo2 = AnalisProperty(prInfo, info, ref recordCount); if (tmInfo2 == null) { break; } PropertyInfoExs prInfos2 = GetProperties(prInfo); CreateInitData(prInfos2, tmInfo2, ref recordCount, level + 1); } else { } } } }
/// <summary> /// Создание начальных записей в левой колонке. /// </summary> public void CreateInitData() { if (DBInterface != null && DBInterface.TableType != null) { MemberInits.Clear(); Type initType = DBInterface.TableType; int recordCount = 0; PropertyInfoExs infos1 = GetProperties(initType); foreach (PropertyInfoEx prInfo1 in infos1) { TableMemberInfo tmInfo2 = AnalisProperty(prInfo1, null, ref recordCount); if (tmInfo2 == null) { break; } MemberInits.Add(tmInfo2); PropertyInfoExs prInfos2 = GetProperties(prInfo1); CreateInitData(prInfos2, tmInfo2, ref recordCount, 1); } lblTotalCount.Caption = string.Format("Всего: {0}", recordCount); treeInit.DataSource = null; treeInit.DataSource = MemberInits; } }
/// <summary> /// Получения списка свойст определенного типа. /// </summary> public PropertyInfoExs GetProperties(PropertyInfoEx info, Type type = null) { Type typeIn; if (type == null) { if (info.IsXPCollection && info.PropertyInfoCollection != null) { typeIn = info.PropertyInfoCollection.PropertyType; } else { typeIn = info.PropertyInfo.PropertyType; } } else { typeIn = type; } PropertyInfoExs result = new PropertyInfoExs(info); if (PropertyInfoEx.isXPComplex(typeIn)) { PropertyInfo[] prInfos = typeIn.GetProperties(); foreach (PropertyInfo prInfoIn in prInfos) { if (prInfoIn.Name != "Loading" && prInfoIn.Name != "IsLoading" && prInfoIn.Name != "IsDeleted" && (PropertyInfoEx.isXPComplex(prInfoIn.PropertyType) || prInfoIn.PropertyType == typeof(bool) || prInfoIn.PropertyType == typeof(short) || prInfoIn.PropertyType == typeof(int) || prInfoIn.PropertyType == typeof(float) || prInfoIn.PropertyType == typeof(double) || prInfoIn.PropertyType == typeof(object) || prInfoIn.PropertyType == typeof(DateTime) || prInfoIn.PropertyType == typeof(string))) { if (!PropertyInfoEx.isXPCollection(prInfoIn.PropertyType)) { result.Add(new PropertyInfoEx(prInfoIn)); } else { PropertyInfo prInfoCollection = prInfoIn.PropertyType.GetProperty("Object"); if (prInfoCollection != null) { result.Add(new PropertyInfoEx(prInfoIn, prInfoCollection)); } } } } } return(result); }