當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET ResXResourceReader.UseResXDataNodes屬性代碼示例

本文整理匯總了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
開發者ID:VB.NET開發者,項目名稱:System.Resources,代碼行數:59,代碼來源:ResXResourceReader.UseResXDataNodes

輸出:

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


注:本文中的System.Resources.ResXResourceReader.UseResXDataNodes屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。