2848.C城市公交查詢系統(tǒng)畢業(yè)設計 外文翻譯_第1頁
2848.C城市公交查詢系統(tǒng)畢業(yè)設計 外文翻譯_第2頁
2848.C城市公交查詢系統(tǒng)畢業(yè)設計 外文翻譯_第3頁
2848.C城市公交查詢系統(tǒng)畢業(yè)設計 外文翻譯_第4頁
2848.C城市公交查詢系統(tǒng)畢業(yè)設計 外文翻譯_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、 外文翻譯城市公交查詢系統(tǒng)的設計與實現(xiàn)學 生 姓 名: 指導教師: 副教授 合作指導教師: 專業(yè)名稱: 計算機科學與技術 所在學院: 水產(chǎn)學院 2009 年6月原文摘自:lvar jacobson.object-oriented software engineering.第1版.北京:人民郵電出版社,2005.10外文資料原文asp.net page object model:summary: learn about the eventing model built around asp.net web pages and the various stages that a web page

2、experiences on its way to html. the asp.net http run time governs the pipeline of objects that transform the requested url into a living instance of a page class first, and into plain html text next. discover the events that characterize the lifecycle of a page and how control and page authors can i

3、ntervene to alter the standard behavior. (6 printed pages)introduction: each request for a microsoft asp.net page that hits microsoft internet information services (iis) is handed over to the asp.net http pipeline. the http pipeline is a chain of managed objects that sequentially process the request

4、 and make the transition from a url to plain html text happen. the entry point of the http pipeline is the httpruntime class. the asp.net infrastructure creates one instance of this class per each appdomain hosted within the worker process (remember that the worker process maintains one distinct app

5、domain per each asp.net application currently running).the httpruntime class picks up an httpapplication object from an internal pool and sets it to work on the request. the main task accomplished by the http application manager is finding out the class that will actually handle the request. when th

6、e request is for an .aspx resource, the handler is a page handlernamely, an instance of a class that inherits from page. the association between types of resources and types of handlers is stored in the configuration file of the application. more exactly, the default set of mappings is defined in th

7、e section of the machine.config file. however, the application can customize the list of its own http handlers in the local web.config file. the line below illustrates the code that defines the http handler for .aspx resources.an extension can be associated with a handler class, or more in general,

8、with a handler factory class. in all cases, the httpapplication object in charge for the request gets an object that implements the ihttphandler interface. if the association resource/class is resolved in terms of a http handler, then the returned class will implement the interface directly. if the

9、resource is bound to a handler factory, an extra step is necessary. a handler factory class implements the ihttphandlerfactory interface whose gethandler method will return an ihttphandler-based object.how can the http run time close the circle and process the page request? the ihttphandler interfac

10、e features the processrequest method. by calling this method on the object that represents the requested page, the asp.net infrastructure starts the process that will generate the output for the browser.the real page classthe type of the http handler for a particular page depends on the url. the fir

11、st time the url is invoked, a new class is composed and dynamically compiled to an assembly. the source code of the class is the outcome of a parsing process that examines the .aspx sources. the class is defined as part of the namespace asp and is given a name that mimics the original url. for examp

12、le, if the url endpoint is page.aspx, the name of the class is asp.page_aspx. the class name, though, can be programmatically controlled by setting the classname attribute in the page directive.the base class for the http handler is page. this class defines the minimum set of methods and properties

13、shared by all page handlers. the page class implements the ihttphandler interface.under a couple of circumstances, the base class for the actual handler is not page but a different class. this happens, for example, if code-behind is used. code-behind is a development technique that insulates the cod

14、e necessary to a page into a separate c# or microsoft visual basic.net class. the code of a page is the set of event handlers and helper methods that actually create the behavior of the page. this code can be defined inline using the tag or placed in an external classthe code-behind class. a code-be

15、hind class is a class that inherits from page and specializes it with extra methods. when specified, the code-behind class is used as the base class for the http handler.the other situation in which the http handler is not based on page is when the configuration file of the application contains a re

16、definition for the pagebasetype attribute in the section.the pagebasetype attribute indicates the type and the assembly that contains the base class for page handlers. derived from page, this class can automatically endow handlers with a custom and extended set of methods and properties.the page lif

17、ecycleonce the http page handler class is fully identified, the asp.net run time calls the handlers processrequest method to process the request. normally, there is no need to change the implementation of the method as it is provided by the page class.this implementation begins by calling the method

18、 frameworkinitialize, which builds the controls tree for the page. the method is a protected and virtual member of the templatecontrol classthe class from which page itself derives. any dynamically generated handler for an .aspx resource overrides frameworkinitialize. in this method, the whole contr

19、ol tree for the page is built.next, processrequest makes the page transit various phases: initialization, loading of view state information and postback data, loading of the pages user code and execution of postback server-side events. after that, the page enters in rendering mode: the updated view

20、state is collected; the html code is generated and then sent to the output console. finally, the page is unloaded and the request is considered completely served.during the various phases, the page fires a few events that web controls and user-defined code can intercept and handle. some of these eve

21、nts are specific for embedded controls and subsequently cant be handled at the level of the .aspx code.a page that wants to handle a certain event should explicitly register an appropriate handler. however, for backward compatibility with the earlier visual basic programming style, asp.net also supp

22、orts a form of implicit event hooking. by default, the page tries to match special method names with events; if a match is found, the method is considered a handler for the event. asp.net provides special recognition of six method names. they are page_init, page_load, page_databind, page_prerender,

23、and page_unload. these methods are treated as handlers for the corresponding events exposed by the page class. the http run time will automatically bind these methods to page events saving developers from having to write the necessary glue code. for example, the method named page_load is wired to th

24、e pages load event as if the following code was written.this.load += new eventhandler(this.page_load);the automatic recognition of special names is a behavior under the control of the autoeventwireup attribute of the page directive. if the attribute is set to false, any applications that wish to han

25、dle an event need to connect explicitly to the page event. pages that dont use automatic event wire-up will get a slight performance boost by not having(51-aspx) to do the extra work of matching names and events. you should note that all microsoft visual studio .net projects are created with the aut

26、oeventwireup attribute disabled. however, the default setting for the attribute is true, meaning that methods such as page_load are recognized and bound to the associated event.the execution of a page consists of a sequence of stages listed in the following table and is characterized by application-

27、level events and/or protected, overridable methods.table 1. key events in the life of an asp.net pagestagepage eventoverridable methodpage initializationinitview stateloadingloadviewstatepostback data processingloadpostdata method in any control that implements the ipostbackdatahandler interfacepage

28、 loadingloadpostback change notificationraise51posaspxtdatachangedevent method in any control that implements the ipostbackdatahandler interfacepostback event handlingany postback event defined by controlsraisepostbackevent method in any control that implements the ipostbackeventhandler interface pa

29、ge pre-rendering phaseprerenderview state savingsaveviewstatepage renderingrenderpage unloadingunloadsome of the stages listed above are not visible at the page level and affect only authors of server controls and developers who happen to create a class derived from page. init, load, prerender, unlo

30、ad, plus all postback events defined by embedded controls are the only signals of life that a page sends to the external world.stages of executionthe first stage in the page lifecycle is the initialization. this stage is characterized by the init event, which fires to the application after the pages

31、 control tree has been successfully created. in other words, when the init event arrives, all the controls statically declared in the .aspx source file have been instantiated and hold their default values. controls can hook up the init event to initialize any settings that will be needed during the

32、lifetime of the incoming web request. for example, at this time controls can load external template files or set up the handler for the events. you should notice that no view state information is available for use yet.immediately after initialization, the page framework loads the view state for the

33、page. the view state is a collection of name/value pairs, where controls and the page itself store any information that must be persistent across web requests. the view state represents the call context of the page. typically, it contains the state of the controls the last time the page was processe

34、d on the server. the view state is empty the first time the page is requested in the session. by default, the view state is stored in a hidden field silently added to the page. the name of this field is _viewstate. by overriding the loadviewstate methoda protected overridable method on the control c

35、lasscomponent developers can control how the view state is restored and how its contents are mapped to the internal state.methods like loadpagestatefrompersistencemedium and its counterpart savepagestatetopersistencemedium can be used to load and save the view state to an alternative storage mediumf

36、or example, session, databases, or a server-side file. unlike loadviewstate, the aforementioned methods are available only in classes derived from page.once the view state has been restored, the controls in the page tree are in the same state they were the last time the page was rendered to the brow

37、ser. the next step consists of updating their state to incorporate client-side changes. the postback data-processing stage gives controls a chance to update their state so that it accurately reflects the state of the corresponding html element on the client. for example, a server textbox control has

38、 its html counterpart in an element. in the postback data stage, the textbox control will retrieve the current value of tag and use it to refresh its internal state. each control is responsible for extracting values from posted data and updating some of its properties. the textbox control will updat

39、e its text property whereas the checkbox control will refresh its checked property. the match between a server control and a html element is found on the id of both.at the end of the postback data processing stage, all controls in the page reflect the previous state updated with changes entered on t

40、he client. at this point, the load event is fired to the page.there might be controls in the page that need to accomplish certain tasks if a sensitive property is modified across two different requests. for example, if the text of a textbox control is modified on the client, the control fires the te

41、xtchanged event. each control can take the decision to fire an appropriate event if one or more of its properties are modified with the values coming from the client. controls for which these changes are critical implement the ipostbackdatahandler interface, whose loadpostdata method is invoked imme

42、diately after the load event. by coding the loadpostdata method, a control verifies if any critical change has occurred since last request and fires its own change event.the key event in the lifecycle of a page is when it is called to execute the server-side code associated with an event triggered o

43、n the client. when the user clicks a button, the page posts back. the collection of posted values contains the id of the button that started the whole operation. if the control is known to implement the ipostbackeventhandler interface (buttons and link buttons will do), the page framework calls the

44、raisepostbackevent method. what this method does depends on the type of the control. with regard to buttons and link buttons, the method looks up for a click event handler and runs the associated delegate.after handling the postback event, the page prepares for rendering. this stage is signaled by t

45、he pretender event. this is a good time for controls to perform any last minute update operations that need to take place immediately before the view state is saved and the output rendered. the next state is saveviewstate, in which all controls and the page itself are invited to flush the contents o

46、f their own viewstate collection. the resultant view state is then serialized, hashed, base64 encoded, and associated with the _viewstate hidden field.the rendering mechanism of individual controls can be altered by overriding the render method. the method takes an html writer object and uses it to

47、accumulate all html text to be generated for the control. the default implementation of the render method for the page class consists of a recursive call to all constituent controls. for each control the page calls the render method and caches the html output.the final sign of life of a page is the

48、unload event that arrives just before the page object is dismissed. in this event you should release any critical resource you might have (for example, files, graphical objects, database connections).finally, after this event the browser receives the http response packet and displays the page.summar

49、ythe asp.net page object model is particularly innovative because of the eventing mechanism. a web page is composed of controls that both produce a rich html-based user interface and interact with the user through events. setting up an eventing model in the context of web applications is challenging

50、. its amazing to see that client-side generated events are resolved with server-side code, and the output of this is visible as the same html page, only properly modified.to make sense of this model it is important to understand the various stages in the page lifecycle and how the page object is ins

51、tantiated and used by the http run time.譯成中文:asp.net 頁面對象模型:摘要:了解圍繞 asp.net web 頁構建的事件模型,以及一個 web 頁面在其轉(zhuǎn)變?yōu)?html 的歷程中的各個階段。asp.net http 運行時控制對象管線,對象管線首先將所請求的 url 轉(zhuǎn)換為一個頁面類的活動實例,然后將其轉(zhuǎn)換為普通 html 文本。本文將探討一個頁面的生存周期中的各個特征事件,并了解控件和頁面編寫者如何介入其中以改變其標準行為。簡介:microsoft internet 信息服務 (iis) 所收到的對某 microsoft asp.net 頁

52、面的每個請求都被移交給 asp.net http 管線。http 管線由一系列托管對象組成,這些對象按順序處理該請求,并完成從 url 到普通 html 文本的轉(zhuǎn)換。http 管線的入口點是 httpruntime 類。asp.net 基礎結構為輔助進程中所承載的每個 appdomain 創(chuàng)建此類的一個實例(請注意,該輔助進程為當前正在運行的每個 asp.net 應用程序維護一個不同的 appdomain)。httpruntime 類從內(nèi)部池中選取一個 httpapplication 對象,并讓其處理該請求。http 應用程序管理器所完成的主要任務就是找出將實際處理該請求的類。如果請求 .as

53、px 資源,則處理程序就是一個頁面處理程序 即某個繼承自 page 的類的一個實例。資源類型和處理程序類型之間的關聯(lián)關系存儲于該應用程序的配置文件中。更準確地說,在 machine.config 文件的 部分中定義默認的一組映射關系。然而,應用程序也可以在本地的 web.config 文件中自定義自己的 http 處理程序列表。下面的程序行舉例說明了定義用于 .aspx 資源的 http 處理程序的代碼。擴展名可關聯(lián)到一個處理程序類,或者更普遍地關聯(lián)到一個處理程序工廠 (handler factory) 類。在所有情況下,負責處理請求的 httpapplication 對象都會獲得一個實現(xiàn) i

54、httphandler 接口的對象。如果根據(jù) http 處理程序來解析關聯(lián)資源/類,那么所返回的類將直接實現(xiàn)該接口。如果資源綁定到處理程序工廠,則需要另外一個步驟。處理程序工廠類實現(xiàn) ihttphandlerfactory 接口,而該接口的 gethandler 方法返回一個基于 ihttphandler 的對象。http 運行時如何能完成整個循環(huán)并處理頁面請求呢?ihttphandler 接口特別提供了 processrequest 方法。通過對代表所請求頁面的對象調(diào)用此方法,asp.net 基礎結構啟動相應過程,從而針對瀏覽器生成輸出。真正的 page 類特定頁面的 http 處理程序類型

55、取決于 url。當首次調(diào)用 url 時,將構建一個新類并將該類動態(tài)地編譯成一個程序集。用于檢查 .aspx 來源的語法分析過程的輸出結果就是該類的源代碼。該類被定義為 asp 命名空間的一部分,并被賦予一個與原始 url 相似的名稱。例如,如果 url 終結點是 page.aspx,則類名稱為 asp.page_aspx。但是,也可通過編程設置 page 指令的 classname 屬性來控制類的名稱。http 處理程序的基類是 page。此類定義了所有頁面處理程序所共享的方法和屬性的最小集合。page 類中實現(xiàn) ihttphandler 接口。在某些情況下,實際處理程序的基類并非 page,

56、而是一個不同的類。例如,如果使用了代碼隱藏,就會出現(xiàn)這種情況。代碼隱藏是一種開發(fā)方法,它將頁面所需的代碼封裝到一個單獨的 c# 或 microsoft visual basic.net 類中。頁面的代碼就是一組事件處理程序和幫助器方法,用以實際創(chuàng)建該頁面的行為??梢岳?標記將這種代碼定義為內(nèi)聯(lián)代碼,或者也可將其放到一個外部類 代碼隱藏類中。代碼隱藏類是一種繼承自 page 的類,但這種類具有一些額外的方法因而比較特殊。如果指定,代碼隱藏類就用作 http 處理程序的基類。還有一種情況,即當應用程序配置文件的 部分中重新定義了 pagebasetype 屬性時,http 處理程序也不是基于 p

57、age 的。pagebasetype 屬性指出了包含頁面處理程序的基類的類型以及程序集。派生自 page 的這個類可自動給處理程序賦予一組自定義和擴展的方法和屬性。頁面生存周期一旦完全確定 http 頁面處理程序類,asp.net 運行時就調(diào)用該處理程序的 processrequest 方法以處理請求。通常情況下,無需更改此方法的實現(xiàn)方式,因為它是由 page 類提供的。此實現(xiàn)方法一開始就調(diào)用 frameworkinitialize 方法,以此建立頁面的控件樹。此方法是 templatecontrol 類(page 類本身就是從該類派生出來的)的一個受保護的虛擬成員。任何針對 .aspx 資源而動態(tài)生成的處理程序都重寫 frameworkinitialize。在此方法中,該頁面的完整控件樹得以構建。接下來,processrequest 使該頁面經(jīng)歷若干階段:初始化,加載視圖狀態(tài)信息和回發(fā)數(shù)據(jù),加載頁面的用戶代碼并執(zhí)行回發(fā)服務器端事件。隨后,該頁面進入呈現(xiàn)模式:收集更新后的視圖狀態(tài);生成 htm

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論