object ConvertValue(IType expectedType, object value) { if (expectedType.IsEnum) { return Convert.ChangeType(value, GetEnumUnderlyingType(expectedType)); } return Convert.ChangeType(value, GetSystemType(expectedType)); }