public static object ValueFromConvertible (Type type, IConvertible value)
{
if (type == typeof (string))
return Convert.ToString (value);
if (type == typeof (bool))
return Convert.ToBoolean (value);
if (type == typeof (byte))
return Convert.ToByte (value);
if (type == typeof (char))
return Convert.ToChar (value);
if (type == typeof (DateTime))
return Convert.ToDateTime (value);
if (type == typeof (Decimal))
return Convert.ToDecimal (value);
if (type == typeof (double))
return Convert.ToDouble (value);
if (type == typeof (Int16))
return Convert.ToInt16 (value);
if (type == typeof (Int32))
return Convert.ToInt32 (value);
if (type == typeof (Int64))
return Convert.ToInt64 (value);
if (type == typeof (SByte))
return Convert.ToSByte (value);
if (type == typeof (Single))
return Convert.ToSingle (value);
if (type == typeof (UInt16))
return Convert.ToUInt16 (value);
if (type == typeof (UInt32))
return Convert.ToUInt32 (value);
if (type == typeof (UInt64))
return Convert.ToUInt64 (value);
return value;
}