namespace Yw.WinFrmUI
{
///
///
///
[TypeConverter(typeof(ExpandableObjectConverter))]
public class DictionaryPropertyAdapter : ICustomTypeDescriptor
{
///
///
///
public DictionaryPropertyAdapter(IDictionary d)
{
_dictionary = d;
}
///
///
///
public IDictionary Dictionary
{
get { return _dictionary; }
}
private IDictionary _dictionary;
///
///
///
public string GetComponentName()
{
return TypeDescriptor.GetComponentName(this, true);
}
///
///
///
public EventDescriptor GetDefaultEvent()
{
return TypeDescriptor.GetDefaultEvent(this, true);
}
///
///
///
public string GetClassName()
{
return TypeDescriptor.GetClassName(this, true);
}
///
///
///
public EventDescriptorCollection GetEvents(Attribute[] attributes)
{
return TypeDescriptor.GetEvents(this, attributes, true);
}
EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents()
{
return TypeDescriptor.GetEvents(this, true);
}
///
///
///
public TypeConverter GetConverter()
{
return TypeDescriptor.GetConverter(this, true);
}
///
///
///
public object GetPropertyOwner(PropertyDescriptor pd)
{
return _dictionary;
}
///
///
///
public AttributeCollection GetAttributes()
{
return TypeDescriptor.GetAttributes(this, true);
}
///
///
///
public object GetEditor(Type editorBaseType)
{
return TypeDescriptor.GetEditor(this, editorBaseType, true);
}
///
///
///
public PropertyDescriptor GetDefaultProperty()
{
return null;
}
PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties()
{
return ((ICustomTypeDescriptor)this).GetProperties(new Attribute[0]);
}
///
///
///
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);
}
}
}