Share via


SiteMapNode.GetExplicitResourceString(String, String, Boolean) 方法

定義

根據要當地語系化的 SiteMapNode 屬性,擷取當地語系化字串、找不到資源時所傳回的預設字串,以及指出找不到資源時是否擲回例外狀況之布林值。

protected:
 System::String ^ GetExplicitResourceString(System::String ^ attributeName, System::String ^ defaultValue, bool throwIfNotFound);
protected string GetExplicitResourceString (string attributeName, string defaultValue, bool throwIfNotFound);
member this.GetExplicitResourceString : string * string * bool -> string
Protected Function GetExplicitResourceString (attributeName As String, defaultValue As String, throwIfNotFound As Boolean) As String

參數

attributeName
String

要當地語系化的 SiteMapNode 屬性。

defaultValue
String

如果找不到相符資源時,要傳回的預設值。

throwIfNotFound
Boolean

如果已定義 attributeName 的明確資源、defaultValuetrue,並且找不到當地語系化值時,要擲回 InvalidOperationException,則為 null,否則為 false

傳回

表示當地語系化屬性的字串。

例外狀況

attributeNamenull

找不到相符的資源物件,並且 throwIfNotFoundtrue

備註

方法 GetExplicitResourceString 會在 屬性的 Title 存取子中叫 get 用、 Description 屬性,以及 屬性中 Attributes 定義的任何自訂屬性。 所 SiteMapProvider 追蹤 的物件 SiteMapNode 必須 EnableLocalization 將其 屬性設定 trueGetExplicitResourceString 為 ,方法才能傳回當地語系化字串。 EnableLocalization如果 設定 false 為 ,則不會執行當地語系化,而且 GetExplicitResourceString 永遠不會呼叫 方法。

屬性 TitleDescription 屬性,以及屬性中 Attributes 定義的任何自訂屬性,會先叫用 GetImplicitResourceString 方法。 如果傳回 null ,則會 GetExplicitResourceString 叫用 方法 defaultValue ,並將 設定為明確資源運算式中的預設值值, (假設已定義一個) ,並將 throwIfNotFound 設定為 true

注意

類別 XmlSiteMapProvider 會強制限制 SiteMapNode 物件無法同時定義隱含資源運算式和屬性的明確資源運算式。 不過,自訂提供者實作可以選擇允許這兩者。

方法 GetExplicitResourceString 會使用 NameValueCollection 物件初始化的資源索引鍵 SiteMapNode 集合。 如果未指定資源索引鍵的集合,則會 GetExplicitResourceStringnull 回 。

適用於

另請參閱