Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LocalizableString.cs
Go to the documentation of this file.
3
5
6internal sealed class LocalizableString
7{
8 private readonly string _propertyName;
9
10 private Func<string> _cachedResult;
11
12 private string _propertyValue;
13
14 [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
16
17 public string Value
18 {
19 get
20 {
21 return _propertyValue;
22 }
23 set
24 {
25 if (_propertyValue != value)
26 {
27 ClearCache();
29 }
30 }
31 }
32
33 [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
35 {
36 get
37 {
38 return _resourceType;
39 }
40 set
41 {
42 if (_resourceType != value)
43 {
44 ClearCache();
46 }
47 }
48 }
49
50 public LocalizableString(string propertyName)
51 {
52 _propertyName = propertyName;
53 }
54
55 private void ClearCache()
56 {
57 _cachedResult = null;
58 }
59
60 public string GetLocalizableValue()
61 {
62 if (_cachedResult == null)
63 {
64 if (_propertyValue == null || _resourceType == null)
65 {
67 }
68 else
69 {
70 PropertyInfo property = _resourceType.GetRuntimeProperty(_propertyValue);
71 bool flag = false;
72 if (!_resourceType.IsVisible || property == null || property.PropertyType != typeof(string))
73 {
74 flag = true;
75 }
76 else
77 {
78 MethodInfo getMethod = property.GetMethod;
79 if (getMethod == null || !getMethod.IsPublic || !getMethod.IsStatic)
80 {
81 flag = true;
82 }
83 }
84 if (flag)
85 {
87 _cachedResult = delegate
88 {
89 throw new InvalidOperationException(exceptionMessage);
90 };
91 }
92 else
93 {
94 _cachedResult = () => (string)property.GetValue(null, null);
95 }
96 }
97 }
98 return _cachedResult();
99 }
100}
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string LocalizableString_LocalizationFailed
Definition SR.cs:56
Definition SR.cs:7
bool IsVisible
Definition Type.cs:364
string? FullName
Definition Type.cs:47