Exemplo n.º 1
0
        public ResourceDescription(ITableType tableType)
        {
            var type = tableType.TypeName;

            this.ResourceName = type.Name;

            //遍历所有自定义属性
            foreach (var one in type.GetProperties())
            {
                ObsoleteAttribute obsolete = Attribute.GetCustomAttribute(one, typeof(ObsoleteAttribute)) as ObsoleteAttribute;
                ColumnAttribute   att      = Attribute.GetCustomAttribute(one, typeof(ColumnAttribute)) as ColumnAttribute;
                if (att == null)
                {
                    continue;
                }

                FieldDefine rf = GetPropertyInfo(one, att, obsolete);
                if (rf == null)
                {
                    continue;
                }

                Fields.Add(rf);
            }
        }
Exemplo n.º 2
0
        private FieldDefine GetPropertyInfo(PropertyInfo pi, ColumnAttribute att, ObsoleteAttribute obsolete)
        {
            FieldDefine rh = new FieldDefine
            {
                FieldName = pi.Name, ColumnName = att.Comment, Width = att.Width, Type = pi.PropertyType
            };

            if (!string.IsNullOrEmpty(att.StructType))
            {
                rh.Type = Type.GetType(att.StructType);
            }

            return(rh);
        }