Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ResourceSet.cs
Go to the documentation of this file.
3using System.IO;
4
5namespace System.Resources;
6
8{
10
12
14
15 protected ResourceSet()
16 {
18 }
19
20 internal ResourceSet(bool junk)
21 {
22 }
23
24 public ResourceSet(string fileName)
25 : this()
26 {
27 Reader = new ResourceReader(fileName);
29 }
30
32 : this()
33 {
34 Reader = new ResourceReader(stream);
36 }
37
39 : this()
40 {
41 Reader = reader ?? throw new ArgumentNullException("reader");
43 }
44
45 public virtual void Close()
46 {
47 Dispose(disposing: true);
48 }
49
50 protected virtual void Dispose(bool disposing)
51 {
52 if (disposing)
53 {
54 IResourceReader reader = Reader;
55 Reader = null;
56 reader?.Close();
57 }
58 Reader = null;
60 _table = null;
61 }
62
63 public void Dispose()
64 {
65 Dispose(disposing: true);
66 }
67
68 public virtual Type GetDefaultReader()
69 {
70 return typeof(ResourceReader);
71 }
72
73 public virtual Type GetDefaultWriter()
74 {
75 return Type.GetType("System.Resources.ResourceWriter, System.Resources.Writer", throwOnError: true);
76 }
77
79 {
80 return GetEnumeratorHelper();
81 }
82
87
89 {
90 IDictionary table = _table;
91 if (table == null)
92 {
94 }
95 return table.GetEnumerator();
96 }
97
98 public virtual string? GetString(string name)
99 {
100 object objectInternal = GetObjectInternal(name);
101 if (objectInternal is string result)
102 {
103 return result;
104 }
105 if (objectInternal == null)
106 {
107 return null;
108 }
110 }
111
112 public virtual string? GetString(string name, bool ignoreCase)
113 {
114 object objectInternal = GetObjectInternal(name);
115 if (objectInternal is string result)
116 {
117 return result;
118 }
119 if (objectInternal != null)
120 {
122 }
123 if (!ignoreCase)
124 {
125 return null;
126 }
128 if (objectInternal is string result2)
129 {
130 return result2;
131 }
132 if (objectInternal == null)
133 {
134 return null;
135 }
137 }
138
139 public virtual object? GetObject(string name)
140 {
141 return GetObjectInternal(name);
142 }
143
144 public virtual object? GetObject(string name, bool ignoreCase)
145 {
146 object objectInternal = GetObjectInternal(name);
147 if (objectInternal != null || !ignoreCase)
148 {
149 return objectInternal;
150 }
152 }
153
154 protected virtual void ReadResources()
155 {
157 while (enumerator.MoveNext())
158 {
159 _table.Add(enumerator.Key, enumerator.Value);
160 }
161 }
162
163 private object GetObjectInternal(string name)
164 {
165 if (name == null)
166 {
167 throw new ArgumentNullException("name");
168 }
170 if (table == null)
171 {
173 }
174 table.TryGetValue(name, out var value);
175 return value;
176 }
177
178 private object GetCaseInsensitiveObjectInternal(string name)
179 {
181 if (table == null)
182 {
184 }
186 if (dictionary == null)
187 {
189 foreach (KeyValuePair<object, object> item in table)
190 {
191 if (item.Key is string key)
192 {
193 dictionary.Add(key, item.Value);
194 }
195 }
197 }
199 return value;
200 }
201}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void Add(TKey key, TValue value)
virtual Type GetDefaultWriter()
Dictionary< string, object > _caseInsensitiveTable
IDictionaryEnumerator GetEnumeratorHelper()
Dictionary< object, object > _table
virtual void Dispose(bool disposing)
ResourceSet(string fileName)
ResourceSet(IResourceReader reader)
object GetObjectInternal(string name)
virtual ? object GetObject(string name)
virtual IDictionaryEnumerator GetEnumerator()
object GetCaseInsensitiveObjectInternal(string name)
virtual Type GetDefaultReader()
virtual ? object GetObject(string name, bool ignoreCase)
virtual ? string GetString(string name, bool ignoreCase)
virtual ? string GetString(string name)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string InvalidOperation_ResourceNotString_Name
Definition SR.cs:1510
static string ObjectDisposed_ResourceSet
Definition SR.cs:1750
Definition SR.cs:7
static StringComparer OrdinalIgnoreCase
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408
new IEnumerator< T > GetEnumerator()