本文整理匯總了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
示例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
示例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
示例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
示例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
示例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
輸出:
The current culture is pt-BR um --> one três --> three cinco --> five sete --> seven nove --> nine