• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

VB.NET ResourceReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了VB.NET中System.Resources.ResourceReader的典型用法代码示例。如果您正苦于以下问题:VB.NET ResourceReader类的具体用法?VB.NET ResourceReader怎么用?VB.NET ResourceReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ResourceReader类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。

示例1:

' Instantiate a standalone .resources file from its filename.
Dim rr1 As New System.Resources.ResourceReader("Resources1.resources")

' Instantiate a standalone .resources file from a stream.
Dim fs As New System.IO.FileStream(".\Resources2.resources",
                                   System.IO.FileMode.Open)
Dim rr2 As New System.Resources.ResourceReader(fs)
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:7,代码来源:ResourceReader


示例2:

Dim assem As System.Reflection.Assembly = 
             System.Reflection.Assembly.LoadFrom(".\MyLibrary.dll") 
Dim fs As System.IO.Stream = 
             assem.GetManifestResourceStream("MyCompany.LibraryResources.resources")
Dim rr As New System.Resources.ResourceReader(fs)
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:5,代码来源:ResourceReader


示例3: Example

' 导入命名空间
Imports System.Collections
Imports System.Resources

Module Example
   Public Sub Main()
      Console.WriteLine("Resources in ApplicationResources.resources:")
      Dim res As New ResourceReader(".\ApplicationResources.resources")
      Dim dict As IDictionaryEnumerator = res.GetEnumerator()
      Do While dict.MoveNext()
         Console.WriteLine("   {0}: '{1}' (Type {2})", dict.Key, dict.Value, dict.Value.GetType().Name)
      Loop
      res.Close()
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:15,代码来源:ResourceReader

输出:

Resources in ApplicationResources.resources:
Label3: '"Last Name:"' (Type String)
Label2: '"Middle Name:"' (Type String)
Label1: '"First Name:"' (Type String)
Label7: '"State:"' (Type String)
Label6: '"City:"' (Type String)
Label5: '"Street Address:"' (Type String)
Label4: '"SSN:"' (Type String)
Label9: '"Home Phone:"' (Type String)
Label8: '"Zip Code:"' (Type String)
Title: '"Contact Information"' (Type String)
Label12: '"Other Phone:"' (Type String)
Label13: '"Fax:"' (Type String)
Label10: '"Business Phone:"' (Type String)
Label11: '"Mobile Phone:"' (Type String)
Label14: '"Email Address:"' (Type String)
Label15: '"Alternate Email Address:"' (Type String)


示例4: New

<Serializable> Public Structure DateTimeTZI
  Dim [Date] As DateTime
  Dim TimeZone As TimeZoneInfo
   
  Public Sub New([date] As DateTime, tz As TimeZoneInfo)
     Me.[Date] = [date]
     Me.TimeZone = tz
  End Sub
  
  Public Overrides Function ToString() As String
     Return String.Format("{0:dd/MM/yyyy hh:mm:ss tt} {1}", 
                          [Date], TimeZone.StandardName)
  End Function
End Structure
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:14,代码来源:ResourceReader


示例5: Main

' 导入命名空间
Imports System.Drawing
Imports System.IO
Imports System.Resources
Imports System.Runtime.Serialization.Formatters.Binary

Imports System.Text

Module Example
   Public Sub Main()
      ' Bitmap as stream.
      Dim bitmapStream As New MemoryStream()
      Dim bmp As New Bitmap(".\ContactsIcon.jpg")
      bmp.Save(bitmapStream, Imaging.ImageFormat.jpeg)
          
      ' Define resources to be written.
      Using rw As New ResourceWriter(".\ContactResources.resources")
         rw.AddResource("Title", "Contact List")
         rw.AddResource("NColumns", 5)         
         rw.AddResource("Icon", bitmapStream)         
         rw.AddResource("Header1", "Name")
         rw.AddResource("Header2", "City")
         rw.AddResource("Header3", "State")  
         rw.AddResource("VersionDate", New DateTimeTZI(#05/18/2012#, 
                                                       TimeZoneInfo.Local))
         rw.AddResource("ClientVersion", True)
         rw.Generate()
      End Using
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:30,代码来源:ResourceReader


示例6: Example

' 导入命名空间
Imports System.Collections
Imports System.Drawing
Imports System.IO
Imports System.Resources
Imports System.Runtime.Serialization.Formatters.Binary

Module Example
   Public Sub Main()
      Dim rdr As New ResourceReader(".\ContactResources.resources")  
      Dim dict As IDictionaryEnumerator = rdr.GetEnumerator()
      Do While dict.MoveNext()
         Console.WriteLine("Resource Name: {0}", dict.Key)
         Try
            Console.WriteLine("   Value: {0}", dict.Value)
         Catch e As FileNotFoundException
            Console.WriteLine("   Exception: A file cannot be found.")
            DisplayResourceInfo(rdr, CStr(dict.Key), False)
         Catch e As FormatException
            Console.WriteLine("   Exception: Corrupted data.")
            DisplayResourceInfo(rdr, CStr(dict.Key), True)
         Catch e As TypeLoadException
            Console.WriteLine("   Exception: Cannot load the data type.")
            DisplayResourceInfo(rdr, CStr(dict.Key), False)   
         End Try
      Loop 
   End Sub

   Private Sub DisplayResourceInfo(rr As ResourceReader, 
                                   key As String, loaded As Boolean)
      Dim dataType As String = Nothing
      Dim data() As Byte = Nothing
      rr.GetResourceData(key, dataType, data)
            
      ' Display the data type.
      Console.WriteLine("   Data Type: {0}", dataType)
      ' Display the bytes that form the available data.      
      Console.Write("   Data: ")
      Dim lines As Integer = 0
      For Each dataItem In data
         lines += 1
         Console.Write("{0:X2} ", dataItem)
         If lines Mod 25 = 0 Then Console.Write("{0}         ", vbCrLf)
      Next
      Console.WriteLine()
      ' Try to recreate current state of  data.
      ' Do: Bitmap, DateTimeTZI
      Select Case dataType   
         ' Handle internally serialized string data (ResourceTypeCode members).
         Case "ResourceTypeCode.String"
            Dim reader As New BinaryReader(New MemoryStream(data))
            Dim binData As String = reader.ReadString()
            Console.WriteLine("   Recreated Value: {0}", binData)
         Case "ResourceTypeCode.Int32"
            Console.WriteLine("   Recreated Value: {0}", 
                              BitConverter.ToInt32(data, 0))
         Case "ResourceTypeCode.Boolean"
            Console.WriteLine("   Recreated Value: {0}", 
                              BitConverter.ToBoolean(data, 0))
         ' .jpeg image stored as a stream.
         Case "ResourceTypeCode.Stream"  
            Const OFFSET As Integer = 4
            Dim size As Integer = BitConverter.ToInt32(data, 0)
            Dim value As New Bitmap(New MemoryStream(data, OFFSET, size))
            Console.WriteLine("   Recreated Value: {0}", value) 
         ' Our only other type is DateTimeTZI.
         Case Else
            ' No point in deserializing data if the type is unavailable.
            If dataType.Contains("DateTimeTZI") And loaded Then 
               Dim binFmt As New BinaryFormatter()
               Dim value As Object = binFmt.Deserialize(New MemoryStream(data))
               Console.WriteLine("   Recreated Value: {0}", value)
            End If    
      End Select
      Console.WriteLine()
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:77,代码来源:ResourceReader



注:本文中的System.Resources.ResourceReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
VB.NET ResourceWriter类代码示例发布时间:2022-05-24
下一篇:
VB.NET ParameterInfo类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap