/// <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); }
/// <summary> /// Анализ PropertyInfoEx объекта и добавление полученных данных в объект TableMemberInfo. /// </summary> public TableMemberInfo AnalisProperty(PropertyInfoEx propertyInfo, TableMemberInfo tableInfo, ref int recordCount) { TableMemberInfo result = new TableMemberInfo(); result.FieldName = propertyInfo.PropertyInfo.Name; result.Caption = PropertyInfoEx.GetDisplayNameAttribute(propertyInfo.PropertyInfo); result.PropertyType = propertyInfo.PropertyInfo.PropertyType; if (propertyInfo.IsXPCollection) { result.PropertyTypeCollection = propertyInfo.PropertyInfoCollection.PropertyType; } result.IsXPBaseObject = propertyInfo.IsXPBaseObject; result.IsXPCollection = propertyInfo.IsXPCollection; if (result.IsXPBaseObject || result.IsXPCollection) { string name = ""; if (result.IsXPBaseObject) { name = DBAttribute.GetIconFile(result.PropertyType); } if (result.IsXPCollection) { name = DBAttribute.GetIconFile(result.PropertyTypeCollection); } string dir = DBInterface.GetImageFullName(name); if (dir != "" && File.Exists(dir) && !ImageEx.IsExist(imgInit, name)) { imgInit.AddImage(Image.FromFile(dir), name); } result.ImageIndex = ImageEx.GetImageIndex(imgInit, name); result.ImageName = name; } if (tableInfo != null) { tableInfo.Add(result); } if (MemberExists.FindInfo(result) != null) { result.IsUsed = true; } // Ограничение по количеству записей recordCount++; if (recordCount >= RecordCountMax) { return(null); } else { return(result); } }
/// <summary> /// Если ли аттрибут Association. /// </summary> public static string GetAssociationAttribute(PropertyInfoEx info) { DevExpress.Xpo.AssociationAttribute[] associations = info.PropertyInfo.GetCustomAttributes(typeof(AssociationAttribute), false) as DevExpress.Xpo.AssociationAttribute[]; if (associations.Length > 0) { return(associations[0].Name); } return(""); }
/// <summary> /// Принадлежит ли тип к XPObject. /// </summary> public static bool isXPBaseObject(PropertyInfoEx prInfo) { if (!prInfo.IsXPCollection && isXPBaseObject(prInfo.PropertyInfo.PropertyType)) { return(true); } else { return(false); } }