You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@ -0,0 +1,31 @@
|
||||
namespace System.Web.ModelBinding {
|
||||
|
||||
public sealed class ComplexModelBinder : IModelBinder {
|
||||
|
||||
public bool BindModel(ModelBindingExecutionContext modelBindingExecutionContext, ModelBindingContext bindingContext) {
|
||||
ModelBinderUtil.ValidateBindingContext(bindingContext, typeof(ComplexModel), false /* allowNullModel */);
|
||||
|
||||
ComplexModel complexModel = (ComplexModel)bindingContext.Model;
|
||||
foreach (ModelMetadata propertyMetadata in complexModel.PropertyMetadata) {
|
||||
ModelBindingContext propertyBindingContext = new ModelBindingContext(bindingContext) {
|
||||
ModelMetadata = propertyMetadata,
|
||||
ModelName = ModelBinderUtil.CreatePropertyModelName(bindingContext.ModelName, propertyMetadata.PropertyName)
|
||||
};
|
||||
|
||||
// bind and propagate the values
|
||||
IModelBinder propertyBinder = bindingContext.ModelBinderProviders.GetBinder(modelBindingExecutionContext, propertyBindingContext);
|
||||
if (propertyBinder != null) {
|
||||
if (propertyBinder.BindModel(modelBindingExecutionContext, propertyBindingContext)) {
|
||||
complexModel.Results[propertyMetadata] = new ComplexModelResult(propertyBindingContext.Model, propertyBindingContext.ValidationNode);
|
||||
}
|
||||
else {
|
||||
complexModel.Results[propertyMetadata] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user