private static Boolean ToBoolean(object value)
{
string text = value as string;
if (text != null)
{
switch (text.ToLowerInvariant())
{
case "t":
case "true":
case "y":
case "yes":
return true;
case "f":
case "false":
case "n":
case "no":
return false;
default:
throw new InvalidCastException(value.ToString());
}
}
else
{
return Convert.ToBoolean(value);
}
}