Exemple #1
0
        /// <summary>
        /// Создание списка возможных типов таблицы.
        /// </summary>
        public void GenerateInitTables()
        {
            if (DBForm.TypeDiscoveryService != null)
            {
                ICollection types = DBForm.TypeDiscoveryService.GetTypes(typeof(DBViewBase), false);
                foreach (Type actionType in types)
                {
                    if (actionType != typeof(DBViewBase))
                    {
                        ViewMemberInfo info = new ViewMemberInfo();
                        info.ViewType = actionType;
                        info.Caption  = DBAttribute.GetCaption(actionType);

                        string name = DBAttribute.GetIconFile(info.ViewType);

                        string dir = DBForm.GetImageFullName(name);
                        if (dir != "" && File.Exists(dir) && !ImageEx.IsExist(imgInit, name))
                        {
                            imgInit.AddImage(Image.FromFile(dir), name);
                        }

                        info.ImageIndex = ImageEx.GetImageIndex(imgInit, name);
                        info.ImageName  = name;
                        if (MemberExists.FindInfo(info) != null)
                        {
                            info.IsUsed = true;
                        }

                        MemberInits.Add(info);
                    }
                }
                lblTotalCount.Caption = string.Format("Всего: {0}", types.Count);
            }
        }
        /// <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);
            }
        }