如下面的代碼片段所示
public class DefaultModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext
stringmodelName
{
if (modelType
{
object instance;
if (GetValueTypeInstance(controllerContext
modelType
{
return instance;
};
returnActivator
}
objectmodelInstance = Activator
foreach (PropertyInfo property in modelType
{
if (!property
&&property
{
continue;
}
objectpropertyValue;
if (GetValueTypeInstance(controllerContext
property
{
property
}
}
returnmodelInstance;
}
private boolGetValueTypeInstance(ControllerContext controllerContext
stringmodelName
{
var form = HttpContext
string key;
if (null != form)
{
key = form
modelName
if (key != null)
{
value = Convert
return true;
}
}
key = controllerContext
if (null != key)
{
value = Convert
return true;
}
key = controllerContext
if (null != key)
{
value = Convert
return true;
}
value = null;
return false;
}
}
返回目錄
編輯推薦
ASP
Microsoft
Java程序性能優化
Visual C++音頻/視頻技術開發與實戰
[
From:http://tw.wingwit.com/Article/program/net/201311/16105.html