forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSR.vb
More file actions
84 lines (70 loc) · 3.79 KB
/
SR.vb
File metadata and controls
84 lines (70 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
'
' SR.vb
'
' This is a standin for the SR class used throughout FX.
'
Imports System.Resources
Imports System.Text
Namespace System
Friend Class SR
' This method is used to decide if we need to append the exception message parameters to the message when calling SR.Format.
' by default it returns false.
' Native code generators can replace the value this returns based on user input at the time of native code generation.
' Marked as NoInlining because if this is used in an AoT compiled app that is not compiled into a single file, the user
' could compile each module with a different setting for this. We want to make sure there's a consistent behavior
' that doesn't depend on which native module this method got inlined into.
<Global.System.Runtime.CompilerServices.MethodImpl(Global.System.Runtime.CompilerServices.MethodImplOptions.NoInlining)>
Public Shared Function UsingResourceKeys() As Boolean
Return False
End Function
Friend Shared Function GetResourceString(ByVal resourceKey As String, Optional ByVal defaultString As String = Nothing) As String
If (UsingResourceKeys()) Then
Return If(defaultString, resourceKey)
End If
Dim resourceString As String = Nothing
Try
resourceString = ResourceManager.GetString(resourceKey)
Catch ex As MissingManifestResourceException
End Try
' if we are running on desktop, ResourceManager.GetString will just return resourceKey. so
' in this case we'll return defaultString (if it is not null)
If defaultString IsNot Nothing AndAlso resourceKey.Equals(resourceString, StringComparison.Ordinal) Then
Return defaultString
End If
Return resourceString
End Function
Friend Shared Function Format(ByVal resourceFormat As String, ParamArray args() As Object) As String
If args IsNot Nothing Then
If (UsingResourceKeys()) Then
Return resourceFormat + String.Join(", ", args)
End If
Return String.Format(resourceFormat, args)
End If
Return resourceFormat
End Function
<Global.System.Runtime.CompilerServices.MethodImpl(Global.System.Runtime.CompilerServices.MethodImplOptions.NoInlining)>
Friend Shared Function Format(ByVal resourceFormat As String, p1 As Object) As String
If (UsingResourceKeys()) Then
Return String.Join(", ", resourceFormat, p1)
End If
Return String.Format(resourceFormat, p1)
End Function
<Global.System.Runtime.CompilerServices.MethodImpl(Global.System.Runtime.CompilerServices.MethodImplOptions.NoInlining)>
Friend Shared Function Format(ByVal resourceFormat As String, p1 As Object, p2 As Object) As String
If (UsingResourceKeys()) Then
Return String.Join(", ", resourceFormat, p1, p2)
End If
Return String.Format(resourceFormat, p1, p2)
End Function
<Global.System.Runtime.CompilerServices.MethodImpl(Global.System.Runtime.CompilerServices.MethodImplOptions.NoInlining)>
Friend Shared Function Format(ByVal resourceFormat As String, p1 As Object, p2 As Object, p3 As Object) As String
If (UsingResourceKeys()) Then
Return String.Join(", ", resourceFormat, p1, p2, p3)
End If
Return String.Format(resourceFormat, p1, p2, p3)
End Function
End Class
End Namespace