Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RuntimeResourceSet.cs
Go to the documentation of this file.
3using System.IO;
4
5namespace System.Resources;
6
8{
10
12
14
19
26
27 protected override void Dispose(bool disposing)
28 {
29 if (_defaultReader != null)
30 {
31 if (disposing)
32 {
34 }
35 _defaultReader = null;
36 _resCache = null;
38 base.Dispose(disposing);
39 }
40 }
41
43 {
44 return GetEnumeratorHelper();
45 }
46
51
61
62 public override string GetString(string key)
63 {
64 object @object = GetObject(key, ignoreCase: false, isString: true);
65 return (string)@object;
66 }
67
68 public override string GetString(string key, bool ignoreCase)
69 {
70 object @object = GetObject(key, ignoreCase, isString: true);
71 return (string)@object;
72 }
73
74 public override object GetObject(string key)
75 {
76 return GetObject(key, ignoreCase: false, isString: false);
77 }
78
79 public override object GetObject(string key, bool ignoreCase)
80 {
81 return GetObject(key, ignoreCase, isString: false);
82 }
83
84 private object GetObject(string key, bool ignoreCase, bool isString)
85 {
86 if (key == null)
87 {
88 throw new ArgumentNullException("key");
89 }
92 if (defaultReader == null || resCache == null)
93 {
95 }
97 object obj;
99 {
100 int dataPosition;
102 {
103 obj = value.Value;
104 if (obj != null)
105 {
106 return obj;
107 }
108 dataPosition = value.DataPosition;
109 ResourceTypeCode typeCode;
110 return isString ? defaultReader.LoadString(dataPosition) : defaultReader.LoadObject(dataPosition, out typeCode);
111 }
112 dataPosition = defaultReader.FindPosForResource(key);
113 if (dataPosition >= 0)
114 {
116 resCache[key] = value;
117 return obj;
118 }
119 }
120 if (!ignoreCase)
121 {
122 return null;
123 }
124 bool flag = false;
126 if (dictionary == null)
127 {
129 flag = true;
130 }
132 {
133 if (flag)
134 {
136 while (enumeratorInternal.MoveNext())
137 {
138 string key2 = (string)enumeratorInternal.Key;
140 dictionary.Add(key2, value2);
141 }
143 }
144 if (!dictionary.TryGetValue(key, out value))
145 {
146 return null;
147 }
148 if (value.Value != null)
149 {
150 return value.Value;
151 }
152 obj = ReadValue(defaultReader, value.DataPosition, isString, out value);
153 if (value.Value != null)
154 {
156 }
157 }
158 return obj;
159 }
160
161 private static object ReadValue(ResourceReader reader, int dataPos, bool isString, out ResourceLocator locator)
162 {
163 object obj;
164 ResourceTypeCode typeCode;
165 if (isString)
166 {
167 obj = reader.LoadString(dataPos);
168 typeCode = ResourceTypeCode.String;
169 }
170 else
171 {
172 obj = reader.LoadObject(dataPos, out typeCode);
173 }
174 locator = new ResourceLocator(dataPos, ResourceLocator.CanCache(typeCode) ? obj : null);
175 return obj;
176 }
177}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
static readonly FastResourceComparer Default
static object ReadValue(ResourceReader reader, int dataPos, bool isString, out ResourceLocator locator)
override IDictionaryEnumerator GetEnumerator()
RuntimeResourceSet(Stream stream, bool permitDeserialization=false)
override object GetObject(string key)
override string GetString(string key)
override object GetObject(string key, bool ignoreCase)
IDictionaryEnumerator GetEnumeratorHelper()
Dictionary< string, ResourceLocator > _resCache
Dictionary< string, ResourceLocator > _caseInsensitiveTable
object GetObject(string key, bool ignoreCase, bool isString)
override void Dispose(bool disposing)
override string GetString(string key, bool ignoreCase)
static string ObjectDisposed_ResourceSet
Definition SR.cs:1750
Definition SR.cs:7
static StringComparer OrdinalIgnoreCase
new IEnumerator< T > GetEnumerator()
static bool CanCache(ResourceTypeCode value)