freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

asp論文外文翻譯---從底層了解aspnet的結(jié)構(gòu)-jsp程序-閱讀頁

2025-06-06 19:24本頁面
  

【正文】 ensibility points you have to know Abstract One of the main design principles MVC has been designed with is extensibility. Everything (or most of) in the processing pipeline is replaceable so, if you don’t like the conventions (or lack of them) that MVC uses, you can create your own services to support your conventions and inject them into the main pipeline. In this post I’m going to show 13 extensibility points that every MVC developer should know, starting from the beginning of the pipeline and going forward till the rendering of the view. 1. RouteConstraint Usually you could put some constrains on url parameters using regular expressions, but if your constrains depend on something that is not only about the single parameter, you can implement the IRouteConstrains’s method and put your validation logic in it. One example of this is the validation of a date: imagine an url that has year, month and date on different url tokens, and you want to be able to validate that the three parts make a valid date. 9. ControllerBase All controllers inherit from the base class Controller. A good way to encapsulate logic or conventions inside your actions is to create you own layer supertype and have all your controllers to inherit from it. 11. ActionResult MVC es with many different kind of results to render views, to render JSON, plain text, files and to redirect to other actions. But if you need some different kind of result you can write your own ActionResult and implement the ExecuteResult method. For example, if you want to send a PDF file as result you could write your own ActionResult that use a PDF library to generate the PDF. Another possible scenario is the RSS feed: read more about how to write a RssResult in this post. Look at implementing a custom action result when the only peculiarity is how the result is returned to the user. View Engines in MVC. s an IF, make a Helper”. What is an HtmlHelper? Basically it’s just an extension method of the HtmlHelper class, but that’s the only requirement. 本文摘自 10 譯文 2 MVC 中你必須知道的 13 個擴展點 摘要 MVC 設(shè)計的主要原則之一是可擴展性。因此,如果您不喜歡 MVC 所使用的約定(或缺乏某些約定),您可以創(chuàng)建自己的服務(wù)來支持您的約定,并將其注入到主管線中。 通常情況下你可以使用正則表達式對 url參數(shù)進行約束,但如果您的約束不僅僅取決于單一參數(shù),您可以實現(xiàn) IRouteConstrains 的方法,并在其中添加你的驗證邏輯。 RouteHandler 是在路由選擇之后進行處理的組件,它并不僅僅針對 MVC。 ControllerFactory 是基于路由的組件,它選擇正確的 controller 并對其實例化。 但如果您希望使用依賴注入,就不能再使用 default factory,而必須使用支持 IoC的controller factory。 11 ActionInvoker 顧名思義是負責(zé)調(diào)用( invoke) action的。 你會發(fā)現(xiàn)大部分執(zhí)行管線存在于 ControllerActionInvoker類的邏輯之中。 可以參閱 NinjectActionInvoker I developed to allow injection of dependencies inside filters。您也可以實現(xiàn)自己的Method Selector 以改善對于 action 的選擇。 例如,您也許 會希望基于瀏覽器所支持的語言或瀏覽器類型(如移動設(shè)備的瀏覽器或桌面瀏覽器)來進行 action 的選取。 框架中已經(jīng)包含了一些 autorization 過濾器,最有名的莫過于 Authorize 特性,它用來檢查當前用戶是 否允許執(zhí)行該 action。如果您希望實現(xiàn)自己的 authorization,那么必須實現(xiàn)接口。 Action Filters 在 action 執(zhí)行前后執(zhí)行。這可能是您最有可能使用的擴展點,并且在我看來, controller 只關(guān)心它的主要工作,而view所需要的所有其他數(shù)據(jù)都必須從 action過濾器內(nèi)部獲取,這樣 的實現(xiàn)對于一個組織良好的 view來說,是十分關(guān)鍵的。例如,參數(shù) 將映射到方法參數(shù) user的 Address屬性的 City屬性。 更進一步來說,例如,您可能希望從數(shù)據(jù)庫中進行檢索,直接根據(jù) person 的 id將其轉(zhuǎn)換為 Person對象。他的代碼基于 Preview 5,但其理念是一樣的。要想在 action中封裝自己的邏輯和約定,創(chuàng)建自己的父類使所有 Controller 繼承自該類,是一種很好的方式。 OutputCache過濾器也可以作為 ResultFilter的示例。如果您希望在頁面返回給用戶時記錄日志,可以編寫自定義的 RenderFilter,在ActionResult 執(zhí)行之后記錄日志。如果您需要其他類型的 result,可以自定義 ActionResult,并實現(xiàn) ExecuteResult方法。又如 RSS feed,可參見 how to write a RssResult in this post。在我看來,最有趣的引擎就是 Spark。 View Engines in MVC。視圖中不能包含任何代碼,所以輔助方法必須十分方便,使您可以將代碼從視圖中提取出來,放到一個可測試的環(huán)境中去。s an IF, make a Helper)。 你可以從 Rob的文章 Avoiding Tag Soup中了解到為什么說 HtmlHelper 是封裝視圖中代碼的好方法
點擊復(fù)制文檔內(nèi)容
畢業(yè)設(shè)計相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1