本文整理汇总了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;未经允许,请勿转载。 |
请发表评论