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

VB.NET ResourceManager类代码示例

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

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



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

示例1: Example

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

Class Example
    Public Shared Sub Main() 
        Dim day As String
        Dim year As String
        Dim holiday As String
        Dim celebrate As String = "{0} will occur on {1} in {2}." & vbCrLf

        ' Create a resource manager. 
        Dim rm As New ResourceManager("rmc", GetType(Example).Assembly)

        Console.WriteLine("Obtain resources using the current UI culture.")

        ' Get the resource strings for the day, year, and holiday 
        ' using the current UI culture. 
        day = rm.GetString("day")
        year = rm.GetString("year")
        holiday = rm.GetString("holiday")
        Console.WriteLine(celebrate, holiday, day, year)

        ' Obtain the es-MX culture.
        Dim ci As New CultureInfo("es-MX")

        Console.WriteLine("Obtain resources using the es-MX culture.")

        ' Get the resource strings for the day, year, and holiday 
        ' using the es-MX culture.  
        day = rm.GetString("day", ci)
        year = rm.GetString("year", ci)
        holiday = rm.GetString("holiday", ci)

        ' ---------------------------------------------------------------
        ' Alternatively, comment the preceding 3 code statements and 
        ' uncomment the following 4 code statements:
        ' ----------------------------------------------------------------
        ' Set the current UI culture to "es-MX" (Spanish-Mexico).
        '    Thread.CurrentThread.CurrentUICulture = ci
        ' Get the resource strings for the day, year, and holiday 
        ' using the current UI culture. 
        '    day  = rm.GetString("day")
        '    year = rm.GetString("year")
        '    holiday = rm.GetString("holiday")
        ' ---------------------------------------------------------------

        ' Regardless of the alternative that you choose, display a message 
        ' using the retrieved resource strings.
        Console.WriteLine(celebrate, holiday, day, year)
    End Sub 
End Class
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:54,代码来源:ResourceManager

输出:

Obtain resources using the current UI culture.
"5th of May" will occur on Friday in 2006.

Obtain resources using the es-MX culture.
"Cinco de Mayo" will occur on Viernes in 2006.


示例2: Example

' 导入命名空间
Imports System.Resources

Module Example
   Public Sub Main()
      Dim rm As New ResourceManager("Strings", GetType(Example).Assembly)
      Dim timeString As String = rm.GetString("TimeHeader")
      Console.WriteLine("{0} {1:T}", timeString, Date.Now)   
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:10,代码来源:ResourceManager

输出:

The current time is 2:03:14 PM


示例3: Example

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

Module Example
   Sub Main()
      ' Create array of supported cultures
      Dim cultures() As String = {"en-CA", "en-US", "fr-FR", "ru-RU" }
      Dim rnd As New Random()
      Dim cultureNdx As Integer = rnd.Next(0, cultures.Length)
      Dim originalCulture As CultureInfo = Thread.CurrentThread.CurrentCulture
      Dim rm As New ResourceManager("Greetings", GetType(Example).Assembly)
      Try
         Dim newCulture As New CultureInfo(cultures(cultureNdx))
         Thread.CurrentThread.CurrentCulture = newCulture
         Thread.CurrentThread.CurrentUICulture = newCulture
         Dim greeting As String = String.Format("The current culture is {0}.{1}{2}",
                                                Thread.CurrentThread.CurrentUICulture.Name,
                                                vbCrLf, rm.GetString("HelloString"))

         Console.WriteLine(greeting)
      Catch e As CultureNotFoundException
         Console.WriteLine("Unable to instantiate culture {0}", e.InvalidCultureName)
      Finally
         Thread.CurrentThread.CurrentCulture = originalCulture
         Thread.CurrentThread.CurrentUICulture = originalCulture
      End Try
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:30,代码来源:ResourceManager

输出:

The current culture is ru-RU.
Всем привет!


示例4: Example

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

<Assembly:NeutralResourcesLanguage("en")>

Module Example
   Public Sub Main()
      Dim cultureNames() As String = { "en-US", "fr-FR", "ru-RU", "sv-SE" }
      Dim rm As New ResourceManager("DateStrings",
                                    GetType(Example).Assembly)
      
      For Each cultureName In cultureNames
         Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture(cultureName)
         Thread.CurrentThread.CurrentCulture = culture 
         Thread.CurrentThread.CurrentUICulture = culture

         Console.WriteLine("Current UI Culture: {0}", 
                           CultureInfo.CurrentUICulture.Name)
         Dim dateString As String = rm.GetString("DateStart")
         Console.WriteLine("{0} {1:M}.", dateString, Date.Now)                           
         Console.WriteLine()
      Next                                           
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:26,代码来源:ResourceManager

输出:

Current UI Culture: en-US
Today is February 03.

Current UI Culture: fr-FR
Aujourd'hui, c'est le 3 février

Current UI Culture: ru-RU
Сегодня февраля 03.

Current UI Culture: sv-SE
Today is den 3 februari.


示例5: Main

' 导入命名空间
Imports System.IO
Imports System.Reflection
Imports System.Resources

Module Example
   Public Sub Main()
      If Environment.GetCommandLineArgs.Length = 1 Then 
         Console.WriteLine("No filename.")
         Exit Sub
      End If
      Dim filename As String = Environment.GetCommandLineArgs(1).Trim()
      ' Check whether the file exists.
      If Not File.Exists(filename) Then
         Console.WriteLine("{0} does not exist.", filename)
         Exit Sub
      End If   
      
      ' Try to load the assembly.
      Dim assem As Assembly = Assembly.LoadFrom(filename)
      Console.WriteLine("File: {0}", filename)
         
      ' Enumerate the resource files.
      Dim resNames() As String = assem.GetManifestResourceNames()
      If resNames.Length = 0 Then
         Console.WriteLine("   No resources found.")
      End If
      For Each resName In resNames
         Console.WriteLine("   Resource: {0}", resName.Replace(".resources", ""))
      Next
      Console.WriteLine()
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System.Resources,代码行数:33,代码来源:ResourceManager



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
VB.NET ResXResourceSet类代码示例发布时间:2022-05-24
下一篇:
VB.NET LocalPrintServer类代码示例发布时间: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