public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (null != value && this.CanConvertFrom(context, value.GetType()))
{
string s = value as string;
ReinstallModes mode = 0;
// Attempt the simple coversion.
if (TryParse(s, out mode))
{
return mode;
}
else
{
// Try parsing the REINSTALLMODE property values.
foreach (char c in s)
{
if (CharToModeMap.ContainsKey(c))
{
mode |= CharToModeMap[c];
}
else
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Error_InvalidReinstallMode, c), "value");
}
}
return mode;
}
}
return base.ConvertFrom(context, culture, value);
}