Επεξεργασία

Κοινή χρήση μέσω


BamlLocalizer.ExtractResources Method

Definition

Extracts all localizable resources from a BAML stream.

public:
 System::Windows::Markup::Localizer::BamlLocalizationDictionary ^ ExtractResources();
public System.Windows.Markup.Localizer.BamlLocalizationDictionary ExtractResources ();
member this.ExtractResources : unit -> System.Windows.Markup.Localizer.BamlLocalizationDictionary
Public Function ExtractResources () As BamlLocalizationDictionary

Returns

A copy of the localizable resources from a BAML stream, in the form of a BamlLocalizationDictionary.

Examples

The following code example demonstrates how to use the ExtractResources method.


// 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

Applies to

See also