private static bool SetPropertyValue(object instance, PropertyInfo targetProperty, object value)
{
try
{
if (RequiresConversion(targetProperty, value))
{
value = System.Convert.ChangeType(value, targetProperty.PropertyType);
}
targetProperty.SetValue(instance, value, null);
return true;
}
catch (InvalidCastException)
{
// If the conversion is not possible, ignore the exception
return false;
}
}