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,41 @@
|
||||
namespace System.Web.ModelBinding {
|
||||
using System;
|
||||
|
||||
public class DefaultModelBinder : IModelBinder {
|
||||
|
||||
public DefaultModelBinder() {
|
||||
Providers = ModelBinderProviders.Providers;
|
||||
}
|
||||
|
||||
public ModelBinderProviderCollection Providers {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool BindModel(ModelBindingExecutionContext modelBindingExecutionContext, ModelBindingContext bindingContext) {
|
||||
ModelBindingContext newBindingContext = bindingContext;
|
||||
IModelBinder binder = Providers.GetBinder(modelBindingExecutionContext, bindingContext);
|
||||
if (binder == null && !String.IsNullOrEmpty(bindingContext.ModelName)
|
||||
&& bindingContext.ModelMetadata.IsComplexType) {
|
||||
|
||||
// fallback to empty prefix?
|
||||
newBindingContext = new ModelBindingContext(bindingContext) {
|
||||
ModelName = String.Empty,
|
||||
ModelMetadata = bindingContext.ModelMetadata
|
||||
};
|
||||
binder = Providers.GetBinder(modelBindingExecutionContext, newBindingContext);
|
||||
}
|
||||
|
||||
if (binder != null) {
|
||||
bool boundSuccessfully = binder.BindModel(modelBindingExecutionContext, newBindingContext);
|
||||
if (boundSuccessfully) {
|
||||
// run validation
|
||||
newBindingContext.ValidationNode.Validate(modelBindingExecutionContext, parentNode:null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false; // something went wrong
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user