private static object ConvertValue(string valueStr, Type targetType) { object result; if (string.IsNullOrWhiteSpace(valueStr)) { result = ConvertEx.GetTypeDefaultValue(targetType); } else { result = ConvertEx.ConvertToObject(targetType, valueStr); } return(result); }
private static bool TryConvertValue(string valueStr, Type targetType, out object result) { result = null; if (string.IsNullOrWhiteSpace(valueStr)) { return(false); } try { result = ConvertEx.ConvertToObject(targetType, valueStr); return(true); } catch { return(false); } }