first commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.ControlLib.UCHelper
|
||||
{
|
||||
//
|
||||
// 摘要:
|
||||
// 对属性进行排序
|
||||
public class PropertyOrderConverter : TypeConverter
|
||||
{
|
||||
//
|
||||
// 摘要:
|
||||
// 当该属性为展开属性选型时,属性编辑器删除该属性的描述
|
||||
//
|
||||
// 参数:
|
||||
// context:
|
||||
//
|
||||
// culture:
|
||||
//
|
||||
// value:
|
||||
//
|
||||
// destinationType:
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
|
||||
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
|
||||
{
|
||||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, attributes);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
foreach (PropertyDescriptor item in properties)
|
||||
{
|
||||
Attribute attribute = item.Attributes[typeof(PropertyOrderAttribute)];
|
||||
arrayList.Add(new PropertyOrderPair(item.Name, (attribute == null) ? 0f : ((PropertyOrderAttribute)attribute).Order));
|
||||
}
|
||||
|
||||
arrayList.Sort();
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
foreach (PropertyOrderPair item2 in arrayList)
|
||||
{
|
||||
arrayList2.Add(item2.CategoryName);
|
||||
}
|
||||
|
||||
return properties.Sort((string[])arrayList2.ToArray(typeof(string)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user