namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
///
|
/// </summary>
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
public class DictionaryPropertyAdapter : ICustomTypeDescriptor
|
{
|
|
/// <summary>
|
///
|
/// </summary>
|
public DictionaryPropertyAdapter(IDictionary d)
|
{
|
_dictionary = d;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public IDictionary Dictionary
|
{
|
get { return _dictionary; }
|
}
|
private IDictionary _dictionary;
|
|
/// <summary>
|
///
|
/// </summary>
|
public string GetComponentName()
|
{
|
return TypeDescriptor.GetComponentName(this, true);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public EventDescriptor GetDefaultEvent()
|
{
|
return TypeDescriptor.GetDefaultEvent(this, true);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public string GetClassName()
|
{
|
return TypeDescriptor.GetClassName(this, true);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
{
|
return TypeDescriptor.GetEvents(this, attributes, true);
|
}
|
|
EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents()
|
{
|
return TypeDescriptor.GetEvents(this, true);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public TypeConverter GetConverter()
|
{
|
return TypeDescriptor.GetConverter(this, true);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public object GetPropertyOwner(PropertyDescriptor pd)
|
{
|
return _dictionary;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public AttributeCollection GetAttributes()
|
{
|
return TypeDescriptor.GetAttributes(this, true);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public object GetEditor(Type editorBaseType)
|
{
|
return TypeDescriptor.GetEditor(this, editorBaseType, true);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public PropertyDescriptor GetDefaultProperty()
|
{
|
return null;
|
}
|
|
PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties()
|
{
|
return ((ICustomTypeDescriptor)this).GetProperties(new Attribute[0]);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
{
|
ArrayList properties = new ArrayList();
|
foreach (DictionaryEntry e in _dictionary)
|
{
|
properties.Add(new DictionaryPropertyDescriptor(_dictionary, e.Key));
|
}
|
|
PropertyDescriptor[] props =
|
(PropertyDescriptor[])properties.ToArray(typeof(PropertyDescriptor));
|
|
return new PropertyDescriptorCollection(props);
|
}
|
|
|
}
|
}
|