DefaultModelBinder から継承し、XElement 型のプロパティを手動でバインドする独自のカスタム ModelBinder を作成中です。
次のように、「BindProperty」メソッドをオーバーライドする必要があるようです。
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);
}
どのコードを使用する必要がありますか:
A) 投稿されたフォームの値からプロパティの値を取得しますか?
B) この値をプロパティに挿入しますか?
DefaultModelBinder クラスで Reflector を実行して動作を確認しようとしましたが、コードが非常にわかりにくいものでした。
以前にこれを行った人が必要です。