解釋說明VS XML注釋插件常見問題
雖然有許多人對VS XML注釋的插件表示懷疑,但在年復(fù)一年的不斷發(fā)展中,他的插件問題也在不斷提高。保障VS XML注釋的插件穩(wěn)定運(yùn)行是完全有可能的,但前提是要深入理解到底什么是VS XML注釋,及他是怎么運(yùn)作的。
這些手工標(biāo)記是非常有用的,如果恰當(dāng)?shù)卦O(shè)置他們,對導(dǎo)出成外部說明文件將非常有幫助。如果碰到是預(yù)先定義的xml標(biāo)記,編譯器可以把這些注釋以文本輸出;如果是編譯器不認(rèn)識的xml標(biāo)記,編譯器會逐字的把所有內(nèi)容都輸出,這意味著你可以使用自己定義的標(biāo)記。#t#
適當(dāng)?shù)脑O(shè)置,C#編譯器并不格式化VS XML注釋,而是以xml文件輸出。下面的步驟將演示如何讓C#編譯器把VS XML注釋輸出為xml文件。右鍵點(diǎn)擊解決方案資源管理器中的工程項(xiàng),打開工程的屬性頁,點(diǎn)擊屬性。對話框出現(xiàn)后,點(diǎn)擊配置屬性目錄。點(diǎn)擊生成節(jié)點(diǎn)。
在右邊的框中有輸出--xml文檔文件,這里就是設(shè)置叢VS XML注釋生成xml文件的文件名。(注:這里設(shè)置的是相對路徑,不是絕對路徑)。在我的例子中,我使用GiveHelpDoc.xml作為文檔名,如果這里沒有輸入任何值,這將是默認(rèn)設(shè)置。
公認(rèn)的標(biāo)記我把VS XML注釋標(biāo)記分類兩大類:***類是設(shè)置標(biāo)記,我叫他們主標(biāo)記。他們在一組標(biāo)記的開始,而且不會在標(biāo)記內(nèi)部出現(xiàn)。第二類是設(shè)置標(biāo)記包含的標(biāo)記,我叫他們支持標(biāo)記。支持標(biāo)記和html標(biāo)記的區(qū)別在于:支持標(biāo)記采用的是小寫,html標(biāo)記采用的是大寫,顯示了我將要討論的支持標(biāo)記和主標(biāo)記。
GiveHelpTransforms.cs部分代碼:
- namespace GiveHelp
- {
- <remarks>
- Class that contains functions to do transformations to help files.
- The source XML is loaded into the <see cref="SourceXML"/> property
- (e.g. <c><I>obj</I>.SourceXML = "<I>XML goes here</I>"</c>). One of
- the associated member functions (<see cref="GiveTypeListHTMLHelp"/
- >, <see cref="GiveMemberListHTMLHelp"/>, <see
- cref="GiveMemberHTMLHelp"/>)
- is called to initiate and then return the transformation.
- <para>
- <list type="table">
- <listheader>
- <term>Help Page</term>
- <description>Function to call</description>
- </listheader>
- <item><term>List of Types</term>
- <description>GiveTypeListHTMLHelp</description></item>
- <item><term>List of members</term>
- <description>GiveMemberListHTMLHelp</description></item>
- <item><term>Help for a single member</term>
- <description>GiveMemberHTMLHelp</description></item>
- </list>
- </para>
- </remarks>
- <permission cref="">public</permission>
- <example><code>
- // create the class that does translations
- GiveHelpTransforms ght = new GiveHelpTransforms();
- // have it load our XML into the SourceXML property
- ght.LoadXMLFromFile("E:\\Inetpub\\www-
- root\\GiveHelp\\GiveHelpDoc.xml");
- // do the translation and then write out the string
- Response.Write( ght.
- GiveMemberHTMLHelp(Request.QueryString.Get("Type"),
- Request.QueryString.Get("Member")) );
- </code></example>
- public class GiveHelpTransforms
- {