예제 #1
0
        PropertyDescriptorCollection ITypedList.GetItemProperties(PropertyDescriptor[] listAccessors)
        {
            var type = typeof(T);
            // 调用TypeDescriptor获取属性
            var pdc = TypeDescriptor.GetProperties(type);

            if (pdc == null || pdc.Count <= 0)
            {
                return(pdc);
            }

            return(EntityBase.Fix(type, pdc));
        }
예제 #2
0
        PropertyDescriptorCollection ITypedList.GetItemProperties(PropertyDescriptor[] listAccessors)
        {
            Type type = typeof(T);
            // 调用TypeDescriptor获取属性
            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(type);

            if (pdc == null || pdc.Count <= 0)
            {
                return(pdc);
            }

            return(EntityBase.Fix(type, pdc));

            //// 准备字段集合
            //Dictionary<String, FieldItem> dic = new Dictionary<string, FieldItem>();
            ////factory.Fields.ForEach(item => dic.Add(item.Name, item));
            //foreach (FieldItem item in Factory.Fields)
            //{
            //    dic.Add(item.Name, item);
            //}

            //List<PropertyDescriptor> list = new List<PropertyDescriptor>();
            //foreach (PropertyDescriptor item in pdc)
            //{
            //    // 显示名与属性名相同,并且没有DisplayName特性
            //    if (item.Name == item.DisplayName && !ContainAttribute(item.Attributes, typeof(DisplayNameAttribute)))
            //    {
            //        // 添加一个特性
            //        FieldItem fi = null;
            //        if (dic.TryGetValue(item.Name, out fi) && !String.IsNullOrEmpty(fi.DisplayName))
            //        {
            //            DisplayNameAttribute dis = new DisplayNameAttribute(fi.DisplayName);
            //            list.Add(TypeDescriptor.CreateProperty(type, item, dis));
            //            continue;
            //        }
            //    }
            //    list.Add(item);
            //}
            //pdc = new PropertyDescriptorCollection(list.ToArray());

            //return pdc;
        }