I'm in the process of creating my own custom ModelBinder that inherits from DefaultModelBinder, and manually binds XElement-typed properties.
Now it seems that I have to override the 'BindProperty' method, like so:
protected override void BindProperty(
ControllerContext controllerContext,
ModelBindingContext bindingContext,
System.ComponentModel.PropertyDescriptor propertyDescriptor)
{
if (propertyDescriptor.PropertyType == typeof(XElement))
{
// code here to take the POST-ed form value and put it in the property as an XElement instance
}
else
base.BindProperty(controllerContext, bindingContext, propertyDescriptor);
}
What code should I be using to:
A) get the value of the property from the posted Form values?
B) inject this value into the property?
I tried running Reflector on the DefaultModelBinder class to see how it does it, but the code was very confusing.
I need someone who's done this before to walk me through it.