public SetValue ( object instance, |
||
instance | object | Target object to set property at. |
pi | Property info for the property to set. | |
newvalue | object | Value to try to parse. |
culture | ||
return | void |
public void SetValue(object instance, PropertyInfo pi, object newvalue, CultureInfo culture = null)
{
var nullableConverter = new NullableConverter(pi.PropertyType);
object obj;
try
{
obj = nullableConverter.ConvertFrom(null, culture ?? CultureInfo.CurrentCulture, newvalue);
}
catch (Exception)
{
ValidationManager.AddError(pi, "Adf.Business.NotInstantiable", newvalue, pi.Name);
return;
}
pi.SetValue(instance, obj, null);
}