|
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using Bulasoft.Common.Elements;
namespace Bulasoft.Common.Elements
{
public class StringDictionaryConvertor : TypeConverter
{
protected class StringDictionaryPropertyDescriptor : TypeConverter.SimplePropertyDescriptor
{
private string _key;
private Element owner;
public StringDictionaryPropertyDescriptor(Type componentType, string name, Type propertyType, string key, Element owner)
:
base(componentType, name, propertyType)
{
this.owner = owner;
_key = key;
}
public override object GetValue(object component)
{
StringDictionary dict = (StringDictionary)component;
if (dict.ContainsKey(_key))
return (component as StringDictionary)[_key];
else
return null;
}
public override void SetValue(object component, object value)
{
(component as StringDictionary)[_key] = (string)value;
}
}
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return context != null;
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(string);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.