婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > asp.net mvc-Controllerl篇 ControllerDescriptor

asp.net mvc-Controllerl篇 ControllerDescriptor

熱門標(biāo)簽:保山電話外呼管理系統(tǒng)怎么用 太原外呼電銷機(jī)器人費用 電話機(jī)器人廣告話術(shù) 外呼系統(tǒng)用員工身份證 東莞語音電銷機(jī)器人排名 淘寶地圖標(biāo)注如何做 朝陽市地圖標(biāo)注 蘇州銷售外呼系統(tǒng)預(yù)算 使用智能電話機(jī)器人違法嗎
現(xiàn)在我們首先來看看ActionInvoker屬性的定義吧:
復(fù)制代碼 代碼如下:

public IActionInvoker ActionInvoker {
get {
if (_actionInvoker == null) {
_actionInvoker = CreateActionInvoker();
}
return _actionInvoker;
}
set {
_actionInvoker = value;
}
}
protected virtual IActionInvoker CreateActionInvoker() {
return new ControllerActionInvoker();
}

和TempDataProvider屬性定義一樣,大家一定要習(xí)慣這些代碼啊。
而ControllerActionInvoker的定義也很簡單,但是這個類卻不簡單啊。
讓我們來看看你InvokeAction的定義吧:
復(fù)制代碼 代碼如下:

public virtual bool InvokeAction(ControllerContext controllerContext, string actionName) {
if (controllerContext == null) {
throw new ArgumentNullException("controllerContext");
}
if (String.IsNullOrEmpty(actionName)) {
throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName");
}

ControllerDescriptor controllerDescriptor = GetControllerDescriptor(controllerContext);
ActionDescriptor actionDescriptor = FindAction(controllerContext, controllerDescriptor, actionName);
if (actionDescriptor != null) {
FilterInfo filterInfo = GetFilters(controllerContext, actionDescriptor);

try {
AuthorizationContext authContext = InvokeAuthorizationFilters(controllerContext, filterInfo.AuthorizationFilters, actionDescriptor);
if (authContext.Result != null) {
// the auth filter signaled that we should let it short-circuit the request
InvokeActionResult(controllerContext, authContext.Result);
}
else {
if (controllerContext.Controller.ValidateRequest) {
ValidateRequest(controllerContext);
}

IDictionarystring, object> parameters = GetParameterValues(controllerContext, actionDescriptor);
ActionExecutedContext postActionContext = InvokeActionMethodWithFilters(controllerContext, filterInfo.ActionFilters, actionDescriptor, parameters);
InvokeActionResultWithFilters(controllerContext, filterInfo.ResultFilters, postActionContext.Result);
}
}
catch (ThreadAbortException) {
// This type of exception occurs as a result of Response.Redirect(), but we special-case so that
// the filters don't see this as an error.
throw;
}
catch (Exception ex) {
// something blew up, so execute the exception filters
ExceptionContext exceptionContext = InvokeExceptionFilters(controllerContext, filterInfo.ExceptionFilters, ex);
if (!exceptionContext.ExceptionHandled) {
throw;
}
InvokeActionResult(controllerContext, exceptionContext.Result);
}

return true;
}

// notify controller that no method matched
return false;
}

這個方法里面的內(nèi)容不可能一次講完的,我們看看 ControllerDescriptor controllerDescriptor = GetControllerDescriptor(controllerContext);
很明顯ControllerDescriptor是Controller實例的一個包裝類。
復(fù)制代碼 代碼如下:

protected virtual ControllerDescriptor GetControllerDescriptor(ControllerContext controllerContext) {
Type controllerType = controllerContext.Controller.GetType();
ControllerDescriptor controllerDescriptor = DescriptorCache.GetDescriptor(controllerType, () => new ReflectedControllerDescriptor(controllerType));
return controllerDescriptor;
}

從這個方法中,我們可以知道實際返回的是一個ReflectedControllerDescriptor實例,它是ControllerDescriptor的子類,DescriptorCache.GetDescriptor(...)好像是從緩存中獲取的啊,讓我們證實一下吧,先來看看ControllerDescriptorCache的GetDescriptor方法:
復(fù)制代碼 代碼如下:

internal sealed class ControllerDescriptorCache : ReaderWriterCacheType, ControllerDescriptor> {
public ControllerDescriptor GetDescriptor(Type controllerType, FuncControllerDescriptor> creator) {
return FetchOrCreateItem(controllerType, creator);
}
}

FetchOrCreateItem方法很簡單,從緩存中獲取ControllerDescriptor ,如果沒有就創(chuàng)建并加入緩存然后在返回,緩存實現(xiàn)方式其實就是一個字典DictionaryTKey, TValue>。
現(xiàn)在看看ReflectedControllerDescriptor的夠著函數(shù)是否有什么特別之處:
_controllerType = controllerType;
_selector = new ActionMethodSelector(_controllerType);
怎么又有ActionMethodSelector這個東東啊,其構(gòu)造函數(shù)如下
復(fù)制代碼 代碼如下:

public ActionMethodSelector(Type controllerType) {
ControllerType = controllerType;
PopulateLookupTables();
}
private void PopulateLookupTables() {
MethodInfo[] allMethods = ControllerType.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public);
MethodInfo[] actionMethods = Array.FindAll(allMethods, IsValidActionMethod);
AliasedMethods = Array.FindAll(actionMethods, IsMethodDecoratedWithAliasingAttribute);
NonAliasedMethods = actionMethods.Except(AliasedMethods).ToLookup(method => method.Name, StringComparer.OrdinalIgnoreCase);
}

這個方法很簡單,找出ControllerType的所有實例、共有方法,然后在過濾調(diào)不是Action的,最后吧這些Action方法分成兩部分,一部分有別名,一部分沒有別名。
現(xiàn)在我們已經(jīng)得到了ControllerDescriptor實例,下面應(yīng)該來看看ActionDescriptor actionDescriptor = FindAction(controllerContext, controllerDescriptor, actionName);這句代碼了;同樣我們可以確認(rèn)ActionDescriptor實際上一個Action的包裝類。
protected virtual ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName)這個方法實際上就是調(diào)用
ControllerDescriptor類FindAction方法,讓我們看看你ReflectedControllerDescriptor的FindAction方法,該方法很簡單,組要就2句代碼:
復(fù)制代碼 代碼如下:

MethodInfo matched = _selector.FindActionMethod(controllerContext, actionName);
return new ReflectedActionDescriptor(matched, actionName, this);

_selector.FindActionMethod(controllerContext, actionName); 這句就是找到我們需要Action對應(yīng)的MethodInfo。
復(fù)制代碼 代碼如下:

public MethodInfo FindActionMethod(ControllerContext controllerContext, string actionName) {
ListMethodInfo> methodsMatchingName = GetMatchingAliasedMethods(controllerContext, actionName);
methodsMatchingName.AddRange(NonAliasedMethods[actionName]);
ListMethodInfo> finalMethods = RunSelectionFilters(controllerContext, methodsMatchingName);

switch (finalMethods.Count) {
case 0:
return null;

case 1:
return finalMethods[0];

default:
throw CreateAmbiguousMatchException(finalMethods, actionName);
}
}

循環(huán)每個MethodInfo,查找它們的自定義的ActionMethodSelectorAttribute特性,如果有只返回驗證通過的特性。看到ReflectedAttributeCache.GetActionMethodSelectorAttributes(methodInfo)這樣的代碼感覺由于緩存有關(guān),
復(fù)制代碼 代碼如下:

private static ReadOnlyCollectionTAttribute> GetAttributesTMemberInfo, TAttribute>(ConcurrentDictionaryTMemberInfo, ReadOnlyCollectionTAttribute>> lookup, TMemberInfo memberInfo)
where TAttribute : Attribute
where TMemberInfo : MemberInfo {
return lookup.GetOrAdd(memberInfo, mi => new ReadOnlyCollectionTAttribute>((TAttribute[])memberInfo.GetCustomAttributes(typeof(TAttribute), inherit: true)));
}

ReflectedAttributeCache這個類有幾個緩存字典:
ConcurrentDictionaryMethodInfo, ReadOnlyCollectionActionMethodSelectorAttribute>>
ConcurrentDictionaryMethodInfo, ReadOnlyCollectionActionNameSelectorAttribute>>
ConcurrentDictionaryMethodInfo, ReadOnlyCollectionFilterAttribute>>
ConcurrentDictionaryType, ReadOnlyCollectionFilterAttribute>>
默認(rèn)實現(xiàn)ActionMethodSelectorAttribute類主要有以下幾個
AcceptVerbsAttribute
HttpDeleteAttribute
HttpGetAttribute
HttpPostAttribute
HttpPutAttribute
NonActionAttribute
AcceptVerbsAttribute
剩下的就是直接實例一個ReflectedActionDescriptor對象了,這個也沒什么特殊,只是里面有一個驗證方法
復(fù)制代碼 代碼如下:

if (validateMethod) {
string failedMessage = VerifyActionMethodIsCallable(methodInfo);
if (failedMessage != null) {
throw new ArgumentException(failedMessage, "methodInfo");
}
}

用來驗證該方法是否可以執(zhí)行,以下幾種情況經(jīng)不會通過,(1)方法是靜態(tài)方法(2)方法的實例類型不是ControllerBase(3)是否包含泛型參數(shù)如 public ActionResult IndexT>()是非法的,但 public ActionResult Index(Liststring> aa)是合法(4)參數(shù)中不能含有Ref和out。
這篇文章說的很散,我們需要注意一點微軟在mvc里面緩存做的很好了,在前面?zhèn)€將獲取ControllerTyper時它是有緩存的,一次讀取當(dāng)前程序集所有的ControllerType,在這里提到了一個DescriptorCache 緩存每次調(diào)用的ControllerType->ReflectedControllerDescriptor,而ReflectedControllerDescriptor實例會一次去讀該Controller的所有Action方法;這里還有一個ReflectedAttributeCache,緩存每次調(diào)用MethodInfo的所有特性(ActionMethodSelectorAttribute、ActionNameSelectorAttribute、FilterAttribute),當(dāng)然FilterAttribute特性還可以在類上面。
您可能感興趣的文章:
  • ASP.NET MVC中URL地址傳參的兩種寫法
  • 解讀ASP.NET 5 & MVC6系列教程(10):Controller與Action
  • 詳解ASP.NET MVC下的異步Action的定義和執(zhí)行原理
  • ASP.NET MVC使用ActionFilterAttribute實現(xiàn)權(quán)限限制的方法(附demo源碼下載)
  • asp.net MVC利用ActionFilterAttribute過濾關(guān)鍵字的方法
  • 使用ASP.NET MVC 4 Async Action+jQuery實現(xiàn)消息通知機(jī)制的實現(xiàn)代碼
  • ASP.NET MVC:Filter和Action的執(zhí)行介紹
  • asp.net MVC實現(xiàn)無組件上傳圖片實例介紹
  • ASP.NET MVC DropDownList數(shù)據(jù)綁定及使用詳解
  • ASP.NET MVC 控制器與視圖
  • ASP.NET實現(xiàn)MVC中獲取當(dāng)前URL、controller及action的方法

標(biāo)簽:洛陽 綏化 潛江 呼倫貝爾 西藏 阿里 運城 克拉瑪依

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net mvc-Controllerl篇 ControllerDescriptor》,本文關(guān)鍵詞  asp.net,mvc-Controllerl,篇,ControllerDescriptor,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net mvc-Controllerl篇 ControllerDescriptor》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net mvc-Controllerl篇 ControllerDescriptor的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av
    欧美一级欧美一级在线播放| 国产日韩视频一区二区三区| 久久精品视频一区二区| 亚洲天堂福利av| 国产精品自拍av| 91精品国产入口| 亚洲欧美偷拍另类a∨色屁股| 蜜桃av一区二区三区| 91免费观看视频在线| 国产日韩欧美制服另类| 裸体歌舞表演一区二区| 欧美亚洲国产一区二区三区va | 国产欧美日韩三级| 首页亚洲欧美制服丝腿| 99re这里只有精品首页| 日本一区二区三区视频视频| 日本不卡1234视频| 欧美夫妻性生活| 亚洲影院久久精品| 欧美最猛黑人xxxxx猛交| 国产精品三级电影| 懂色av一区二区夜夜嗨| 国产日本欧美一区二区| 激情av综合网| 久久久国产一区二区三区四区小说 | 国产精品天干天干在线综合| 精品一区二区三区久久| 717成人午夜免费福利电影| 亚洲成av人片一区二区三区| 91成人免费在线| 亚洲精品久久7777| 色噜噜狠狠色综合中国| 一二三区精品福利视频| 91久久国产综合久久| 亚洲另类在线一区| 欧美日韩在线亚洲一区蜜芽| 一区二区三国产精华液| 欧美亚洲图片小说| 亚洲v中文字幕| 日韩精品中文字幕一区| 精品一二三四区| 国产欧美精品一区| 一本色道综合亚洲| 亚洲成av人片在线| 亚洲精品一区二区三区在线观看| 狠狠狠色丁香婷婷综合激情| 久久久久久久久久看片| 99精品久久久久久| 午夜精品一区二区三区免费视频| 4438x成人网最大色成网站| 免费观看久久久4p| 国产精品情趣视频| 欧美日韩精品久久久| 美女在线一区二区| 中文字幕的久久| 欧美性猛片xxxx免费看久爱| 天堂蜜桃一区二区三区| 久久久精品国产免大香伊| www.日本不卡| 午夜国产不卡在线观看视频| 精品成人a区在线观看| 99精品欧美一区二区三区小说| 亚洲综合一二区| 欧美精品一区二区三区视频| 成人污污视频在线观看| 亚洲r级在线视频| 久久久777精品电影网影网| 99国内精品久久| 精油按摩中文字幕久久| 亚洲婷婷在线视频| 精品久久久久久久人人人人传媒| 成人性色生活片| 蜜桃精品视频在线观看| 亚洲男人天堂av| 久久久蜜桃精品| 欧美精品精品一区| 99久久99久久久精品齐齐| 久久99精品视频| 亚洲一区二区在线视频| 国产精品免费视频观看| 日韩美女主播在线视频一区二区三区| 成人小视频免费在线观看| 日韩精品一二三| 亚洲综合一区二区| 国产精品夫妻自拍| 一区二区三区在线播| 欧美成人国产一区二区| 欧美色精品天天在线观看视频| 国产999精品久久| 久久国产欧美日韩精品| 一区二区三区日韩在线观看| 中文欧美字幕免费| 久久久久久久久久久久久久久99| 日韩一区二区三区三四区视频在线观看| 成人app网站| 成人激情免费电影网址| 精一区二区三区| 美女在线一区二区| 免费观看一级欧美片| 天堂va蜜桃一区二区三区漫画版| 一区在线观看免费| 中文字幕视频一区二区三区久| 久久久久久夜精品精品免费| 91精品欧美一区二区三区综合在 | 亚洲国产精品ⅴa在线观看| 2欧美一区二区三区在线观看视频| 欧美福利一区二区| 欧美一区二区三区四区高清| 欧美日韩精品福利| 日韩一级黄色片| 精品盗摄一区二区三区| 日韩欧美电影一二三| 日韩亚洲欧美中文三级| 日韩免费电影网站| 久久先锋影音av鲁色资源网| 国产午夜精品一区二区三区嫩草| 久久久国产精品不卡| 久久久久久夜精品精品免费| 国产日韩综合av| 1区2区3区国产精品| 亚洲视频一区二区免费在线观看| 亚洲色图丝袜美腿| 婷婷夜色潮精品综合在线| 老司机精品视频线观看86| 国产一区三区三区| 懂色av一区二区在线播放| 91毛片在线观看| 欧美男男青年gay1069videost| 欧美一区二视频| 久久久精品中文字幕麻豆发布| 国产精品卡一卡二卡三| 亚洲午夜电影在线观看| 天堂影院一区二区| 国产大片一区二区| 91丨porny丨蝌蚪视频| 777午夜精品免费视频| 日韩欧美区一区二| 亚洲天天做日日做天天谢日日欢 | 日韩一卡二卡三卡国产欧美| 久久午夜国产精品| 一卡二卡欧美日韩| 极品少妇一区二区三区精品视频| 国产高清精品久久久久| 欧美午夜在线一二页| 久久先锋影音av| 亚洲图片欧美色图| 成人性生交大片免费看中文网站| 色综合夜色一区| 日韩一区二区三区高清免费看看| 久久久久88色偷偷免费| 亚洲国产aⅴ成人精品无吗| 国产精品一区二区三区乱码| 日本韩国欧美在线| 国产日韩精品一区二区浪潮av| 亚洲愉拍自拍另类高清精品| 国产成人在线免费| 欧美日韩国产中文| 国产精品久线观看视频| 日本欧美久久久久免费播放网| jlzzjlzz欧美大全| 日韩欧美一二三| 午夜在线成人av| 99国产欧美另类久久久精品| 日韩精品自拍偷拍| 石原莉奈在线亚洲三区| 91片在线免费观看| 国产欧美视频在线观看| 日韩制服丝袜先锋影音| 91日韩精品一区| 中文字幕在线播放不卡一区| 美女国产一区二区三区| 欧美色区777第一页| 中文字幕日本乱码精品影院| 国产一区二区美女| 日韩女优电影在线观看| 亚洲成av人片一区二区| 一本色道**综合亚洲精品蜜桃冫 | 麻豆精品久久精品色综合| 色婷婷综合久久久中文字幕| 国产精品网站一区| 成人晚上爱看视频| 欧美国产激情一区二区三区蜜月 | 久久精品久久99精品久久| 欧美日韩国产色站一区二区三区| 中文字幕在线观看不卡| av在线不卡免费看| 亚洲视频 欧洲视频| 成人一区二区三区中文字幕| 国产色综合久久| 国产一区中文字幕| 久久久久久免费| 国产精品18久久久久久久网站| 精品国产欧美一区二区| 久久激情五月婷婷| 久久久蜜臀国产一区二区| 国产黑丝在线一区二区三区| 中文欧美字幕免费| 日本丶国产丶欧美色综合| 亚洲国产日日夜夜| 91精品国产色综合久久|