C# Class SharpArch.Web.Mvc.ModelBinder.SharpModelBinder

Inheritance: System.Web.Mvc.DefaultModelBinder
显示文件 Open project: sharparchitecture/Sharp-Architecture

Protected Methods

Method Description
GetPropertyValue ( System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, IModelBinder propertyBinder ) : object
OnModelUpdating ( System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext ) : bool

Called when the model is updating. We handle updating the Id property here because it gets filtered out of the normal MVC2 property binding.

SetProperty ( System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, object value ) : void

Sets the specified property by using the specified controller context, binding context, and property value.

Private Methods

Method Description
IsEntityType ( Type propertyType ) : bool
IsSimpleGenericBindableEntityCollection ( Type propertyType ) : bool
SetEntityCollectionProperty ( System.Web.Mvc.ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, object value ) : void

If the property being bound is a simple, generic collection of entity objects, then use reflection to get past the protected visibility of the collection property, if necessary.

SetIdProperty ( System.Web.Mvc.ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, object value ) : void

If the property being bound is an Id property, then use reflection to get past the protected visibility of the Id property, accordingly.

Method Details

GetPropertyValue() protected method

protected GetPropertyValue ( System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, IModelBinder propertyBinder ) : object
controllerContext System.Web.Mvc.ControllerContext
bindingContext System.Web.Mvc.ModelBindingContext
propertyDescriptor System.ComponentModel.PropertyDescriptor
propertyBinder IModelBinder
return object

OnModelUpdating() protected method

Called when the model is updating. We handle updating the Id property here because it gets filtered out of the normal MVC2 property binding.
protected OnModelUpdating ( System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext ) : bool
controllerContext System.Web.Mvc.ControllerContext The context within which the controller operates. The context information includes the controller, HTTP content, request context, and route data.
bindingContext System.Web.Mvc.ModelBindingContext The context within which the model is bound. The context includes information such as the model object, model name, model type, property filter, and value provider.
return bool

SetProperty() protected method

Sets the specified property by using the specified controller context, binding context, and property value.
protected SetProperty ( System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, object value ) : void
controllerContext System.Web.Mvc.ControllerContext The context within which the controller operates. The context information includes the controller, HTTP content, request context, and route data.
bindingContext System.Web.Mvc.ModelBindingContext The context within which the model is bound. The context includes information such as the model object, model name, model type, property filter, and value provider.
propertyDescriptor System.ComponentModel.PropertyDescriptor Describes a property to be set. The descriptor provides information such as the component type, property type, and property value. It also provides methods to get or set the property value.
value object The value to set for the property.
return void