共用方式為


BamlLocalizer 類別

定義

從 BAML 檔案擷取資源,並產生 BAML 來源的當地語系化版本。

public ref class BamlLocalizer
public class BamlLocalizer
type BamlLocalizer = class
Public Class BamlLocalizer
繼承
BamlLocalizer

範例

下列範例示範如何使用 BamlLocalizer


// Obtain the BAML stream.
Stream source = entry.Value as Stream;

// Create a BamlLocalizer on the stream.
BamlLocalizer localizer = new BamlLocalizer(source);
BamlLocalizationDictionary resources = localizer.ExtractResources();

// Write out all the localizable resources in the BAML.
foreach (DictionaryEntry resourceEntry in resources)
{
    BamlLocalizableResourceKey key = resourceEntry.Key as BamlLocalizableResourceKey;
    BamlLocalizableResource value = resourceEntry.Value as BamlLocalizableResource;
    Console.WriteLine(
        "    {0}.{1}.{2} = {3}",
        key.Uid,
        key.ClassName,
        key.PropertyName,
        value.Content
        );                                
}

' Obtain the BAML stream.
Dim source As Stream = TryCast(entry.Value, Stream)

' Create a BamlLocalizer on the stream.
Dim localizer As New BamlLocalizer(source)
Dim resources As BamlLocalizationDictionary = localizer.ExtractResources()

' Write out all the localizable resources in the BAML.
For Each resourceEntry As DictionaryEntry In resources
    Dim key As BamlLocalizableResourceKey = TryCast(resourceEntry.Key, BamlLocalizableResourceKey)
    Dim value As BamlLocalizableResource = TryCast(resourceEntry.Value, BamlLocalizableResource)
    Console.WriteLine("    {0}.{1}.{2} = {3}", key.Uid, key.ClassName, key.PropertyName, value.Content)
Next resourceEntry

備註

這個類別是 BAML 當地語系化 API 的主要進入點。 您必須為每個當地語系化的 BAML 來源建立這個類別的實例。

建構函式

BamlLocalizer(Stream)

使用指定的 BAML 來源資料流,初始化 BamlLocalizer 類別的新執行個體。

BamlLocalizer(Stream, BamlLocalizabilityResolver)

使用指定的可當地語系化解析程式 (Resolver) 和 BAML 來源資料流,初始化 BamlLocalizer 類別的新執行個體。

BamlLocalizer(Stream, BamlLocalizabilityResolver, TextReader)

使用指定的可當地語系化解析程式、BAML 來源資料流和 BamlLocalizer,初始化 TextReader 類別的新執行個體。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
ExtractResources()

從 BAML 資料流擷取所有可當地語系化的資源。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnErrorNotify(BamlLocalizerErrorNotifyEventArgs)

引發 ErrorNotify 事件。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
UpdateBaml(Stream, BamlLocalizationDictionary)

將資源更新套用至 BAML 來源,並將更新版本寫入到指定的資料流,以建立來源 BAML 的當地語系化版本。

事件

ErrorNotify

BamlLocalizer 發生異常條件時發生。

適用於

另請參閱