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)

使用指定的本地化解析程序和 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 遇到意外情况时发生。

适用于

另请参阅