当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET ResourceManager.GetObject方法代码示例

本文整理汇总了VB.NET中System.Resources.ResourceManager.GetObject方法的典型用法代码示例。如果您正苦于以下问题:VB.NET ResourceManager.GetObject方法的具体用法?VB.NET ResourceManager.GetObject怎么用?VB.NET ResourceManager.GetObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Resources.ResourceManager的用法示例。


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

示例1: New

<Serializable> Public Structure PersonTable
   Public ReadOnly nColumns As Integer
   Public Readonly column1 As String
   Public ReadOnly column2 As String
   Public ReadOnly column3 As String
   Public ReadOnly width1 As Integer
   Public ReadOnly width2 As Integer
   Public ReadOnly width3 As Integer
   
   Public Sub New(column1 As String, column2 As String, column3 As String,
                  width1 As Integer, width2 As Integer, width3 As Integer)
      Me.column1 = column1
      Me.column2 = column2
      Me.column3 = column3
      Me.width1 = width1
      Me.width2 = width2
      Me.width3 = width3
      Me.nColumns = Me.GetType().GetFields().Count \ 2 
   End Sub
End Structure
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:20,代码来源:ResourceManager.GetObject

示例2: Main

' 导入命名空间
Imports System.Resources

Module CreateResource
   Public Sub Main()
      Dim table As New PersonTable("Name", "Employee Number", "Age", 30, 18, 5)
      Dim rr As New ResXResourceWriter(".\UIResources.resx")
      rr.AddResource("TableName", "Employees of Acme Corporation")
      rr.AddResource("Employees", table)
      rr.Generate()
      rr.Close()
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:13,代码来源:ResourceManager.GetObject

示例3: Example

' 导入命名空间
Imports System.Resources

<Assembly: NeutralResourcesLanguageAttribute("en")>

Module Example
   Public Sub Main()
      Dim fmtString As String = String.Empty
      Dim rm As New ResourceManager("UIResources", GetType(Example).Assembly)       
      Dim title As String = rm.GetString("TableName")
      Dim tableInfo As PersonTable = DirectCast(rm.GetObject("Employees"), PersonTable)

      If Not String.IsNullOrEmpty(title) Then
         fmtString = "{0," + ((Console.WindowWidth + title.Length) \ 2).ToString() + "}" 
         Console.WriteLine(fmtString, title)      
         Console.WriteLine()
      End If

      For ctr As Integer = 1 To tableInfo.nColumns
         Dim columnName As String = "column"  + ctr.ToString()
         Dim widthName As String = "width" + ctr.ToString()
         Dim value As String = CStr(tableInfo.GetType().GetField(columnName).GetValue(tableInfo))
         Dim width As Integer = CInt(tableInfo.GetType().GetField(widthName).GetValue(tableInfo))
         fmtString = "{0,-" + width.ToString() + "}"
         Console.Write(fmtString, value)
      Next      
      Console.WriteLine()
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:29,代码来源:ResourceManager.GetObject

示例4: New

<Serializable> Public Class Numbers
   Public Readonly One As String
   Public ReadOnly Two As String
   Public ReadOnly Three As String
   Public ReadOnly Four As String
   Public ReadOnly Five As String
   Public ReadOnly Six As String
   Public ReadOnly Seven As String
   Public ReadOnly Eight As String
   Public ReadOnly Nine As String
   Public ReadOnly Ten As String
   
   Public Sub New(one As String, two As String, three As String, four As String, 
                  five As String, six As String, seven As String, eight As String,
                  nine As String, ten As String)
      Me.One = one
      Me.Two = two
      Me.Three = three
      Me.Four = four
      Me.Five = five
      Me.Six = six
      Me.Seven = seven
      Me.Eight = eight
      Me.Nine = nine
      Me.Ten = ten                                    
   End Sub                  
End Class
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:27,代码来源:ResourceManager.GetObject

示例5: Main

' 导入命名空间
Imports System.Resources

Module CreateResource
   Public Sub Main()
      Dim en As New Numbers("one", "two", "three", "four", "five",
                            "six", "seven", "eight", "nine", "ten")
      CreateResourceFile(en, "en")
      Dim fr As New Numbers("un", "deux", "trois", "quatre", "cinq", 
                            "six", "sept", "huit", "neuf", "dix")
      CreateResourceFile(fr, "fr")
      Dim pt As New Numbers("um", "dois", "três", "quatro", "cinco", 
                            "seis", "sete", "oito", "nove", "dez")
      CreateResourceFile(pt, "pt") 
      Dim ru As New Numbers("один", "два", "три", "четыре", "пять", 
                            "шесть", "семь", "восемь", "девять", "десять")                                                       
      CreateResourceFile(ru, "ru")
   End Sub

   Public Sub CreateResourceFile(n As Numbers, lang As String)
      Dim filename As String = ".\NumberResources" + 
                               If(lang <> "en", "." + lang, "") +
                               ".resx"
      Dim rr As New ResXResourceWriter(filename)
      rr.AddResource("Numbers", n)
      rr.Generate()
      rr.Close()    
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:29,代码来源:ResourceManager.GetObject

示例6: Example

' 导入命名空间
Imports System.Globalization
Imports System.Resources 
Imports System.Threading

<assembly:NeutralResourcesLanguageAttribute("en-US")>

Module Example
   Dim cultureNames() As String = { "fr-FR", "pt-BR", "ru-RU" }
   
   Public Sub Main()
      ' Make any non-default culture the current culture.
      Dim rnd As New Random
      Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture(cultureNames(rnd.Next(0, cultureNames.Length)))
      Thread.CurrentThread.CurrentUICulture = culture
      Console.WriteLine("The current culture is {0}", CultureInfo.CurrentUICulture.Name)
      Console.WriteLine()
      Dim enCulture As CultureInfo = CultureInfo.CreateSpecificCulture("en-US") 

      Dim rm As New ResourceManager(GetType(NumberResources))
      Dim numbers As Numbers = CType(rm.GetObject("Numbers"), Numbers)
      Dim numbersEn As Numbers = CType(rm.GetObject("Numbers", enCulture), Numbers)
      Console.WriteLine("{0} --> {1}", numbers.One, numbersEn.One) 
      Console.WriteLine("{0} --> {1}", numbers.Three, numbersEn.Three) 
      Console.WriteLine("{0} --> {1}", numbers.Five, numbersEn.Five) 
      Console.WriteLine("{0} --> {1}", numbers.Seven, numbersEn.Seven) 
      Console.WriteLine("{0} --> {1}", numbers.Nine, numbersEn.Nine) 
      Console.WriteLine()       
   End Sub
End Module


Friend Class NumberResources
End Class
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:34,代码来源:ResourceManager.GetObject

输出:

The current culture is pt-BR

um --> one
três --> three
cinco --> five
sete --> seven
nove --> nine


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