localization.vb

来自「sql server report service的例子。给dw开发者」· VB 代码 · 共 34 行

VB
34
字号
Imports System.Reflection
Imports System.Globalization
Imports System.Resources

Public Class Localization

	' Create the resource manager to be used by the method.
	Private Shared LocalizeRM = New ResourceManager("ReportUtil.Localization", System.Reflection.Assembly.GetExecutingAssembly())

	'The line preceding function declaration asserts that this function needs to have FullTrust rights 
	' even though it is called by a process that only has Execution rights.
	'
	'Also, the following line is required in AssemblyInfo.vb in order for the assert to work:
	'
	' <Assembly: Security.AllowPartiallyTrustedCallers()> 

	' This shared method returns the localized version of the string identifier that is passed to it.
	<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Assert, Name:="FullTrust")> _
	Public Shared Function LocalizedString(ByVal stringIdentifier As String, ByVal language As String) As String
		Try
			' Create a CultureInfo object using the specified language.
			Dim currentCulture = New CultureInfo(language)

			' Use the CultureInfo object to return the appropriate string
			' from the resource manager.
			Return LocalizeRM.GetString(stringIdentifier, currentCulture)
		Catch ex As System.Exception
			' Return an error message if the process fails.
			Return ex.Message
		End Try
	End Function

End Class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?