namespace Yw.WinFrmUI
{
///
///
///
public class DictionaryPropertyDescriptor : PropertyDescriptor
{
///
///
///
public DictionaryPropertyDescriptor(IDictionary d, object key) : base(key.ToString(), null)
{
_dictionary = d;
_key = key;
}
private IDictionary _dictionary;
private object _key;
///
///
///
public override Type PropertyType
{
get
{
var value = _dictionary[_key];
if (value == null)
{
return typeof(string);
}
return value.GetType();
}
}
///
///
///
public override void SetValue(object component, object value)
{
_dictionary[_key] = value;
}
///
///
///
public override object GetValue(object component)
{
return _dictionary[_key];
}
///
///
///
public override bool IsReadOnly
{
get { return false; }
}
///
///
///
public override Type ComponentType
{
get { return null; }
}
///
///
///
public override bool CanResetValue(object component)
{
return false;
}
///
///
///
public override void ResetValue(object component)
{
}
///
///
///
public override bool ShouldSerializeValue(object component)
{
return false;
}
}
}