У меня есть пользовательский механизм связывания модели, где я проверяю, являются ли строковые свойства нулевыми, и заменяю их пустыми строками.
Я переопределяю метод BindProperty, но не уверен, как получить значение свойства из PropertyDescriptor
GetPropertyValue(controllerContext, bindingContext, propertyDescriptor,
<What should I pass for the IModelBinder?>);
Вот код BindProperty
protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, System.ComponentModel.PropertyDescriptor propertyDescriptor)
{
if (propertyDescriptor.PropertyType == typeof(string))
{
object s = GetPropertyValue(controllerContext, bindingContext, propertyDescriptor, null);
if (s == null)
{
SetProperty(controllerContext, bindingContext, propertyDescriptor, "");
}
}
}