本文整理匯總了VB.NET中System.Resources.ResXResourceReader.UseResXDataNodes屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET ResXResourceReader.UseResXDataNodes屬性的具體用法?VB.NET ResXResourceReader.UseResXDataNodes怎麽用?VB.NET ResXResourceReader.UseResXDataNodes使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Resources.ResXResourceReader
的用法示例。
在下文中一共展示了ResXResourceReader.UseResXDataNodes屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Main
' 導入命名空間
Imports System.Collections
Imports System.Resources
Imports System.ComponentModel.Design
Namespace UseDataNodesExample
Public Class Program
Public Shared Sub Main()
Console.WriteLine(vbNewLine + "Enumerating as data items...")
EnumResourceItems("Resource1.resx", False)
Console.WriteLine(vbNewLine + "Enumerating as data nodes...")
EnumResourceItems("Resource1.resx", True)
End Sub
Public Shared Sub EnumResourceItems(resxFile As String, useDataNodes As Boolean)
Using reader As New ResXResourceReader(resxFile)
reader.UseResXDataNodes = useDataNodes
' Enumerate using IEnumerable.GetEnumerator().
Console.WriteLine(vbNewLine + " Default enumerator:")
For Each entry As DictionaryEntry In reader
ShowResourceItem(entry, useDataNodes)
Next entry
' Enumerate using GetMetadataEnumerator()
Dim metadataEnumerator As IDictionaryEnumerator = reader.GetMetadataEnumerator()
Console.WriteLine(vbNewLine + " MetadataEnumerator:")
While metadataEnumerator.MoveNext()
ShowResourceItem(metadataEnumerator.Entry, useDataNodes)
End While
' Enumerate using GetEnumerator()
Dim enumerator As IDictionaryEnumerator = reader.GetEnumerator()
Console.WriteLine(vbNewLine + " Enumerator:")
While enumerator.MoveNext()
ShowResourceItem(enumerator.Entry, useDataNodes)
End While
End Using
End Sub
Public Shared Sub ShowResourceItem(entry As DictionaryEntry, isDataNode As Boolean)
' Use a Nothing type resolver.
Dim typeres As ITypeResolutionService = Nothing
Dim dnode As ResXDataNode
If isDataNode Then
' Display from node info.
dnode = CType(entry.Value, ResXDataNode)
Console.WriteLine(" {0}={1}", dnode.Name, dnode.GetValue(typeres))
Else
' Display as DictionaryEntry info.
Console.WriteLine(" {0}={1}", entry.Key, entry.Value)
End If
End Sub
End Class
End Namespace
輸出:
Enumerating as data items... Default enumerator: DataSample=Sample DATA value MetadataEnumerator: MetadataSample=Sample METADATA value Enumerator: DataSample=Sample DATA value Enumerating as data nodes... Default enumerator: DataSample=Sample DATA value MetadataSample=Sample METADATA value MetadataEnumerator: Enumerator: DataSample=Sample DATA value MetadataSample=Sample METADATA value