Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlBinaryReaderSession.cs
Go to the documentation of this file.
4
5namespace System.Xml;
6
8{
9 private const int MaxArrayEntries = 2048;
10
12
14
15 public XmlDictionaryString Add(int id, string value)
16 {
17 if (id < 0)
18 {
20 }
21 if (value == null)
22 {
24 }
25 if (TryLookup(id, out XmlDictionaryString result))
26 {
28 }
29 result = new XmlDictionaryString(this, value, id);
30 if (id >= 2048)
31 {
32 if (_stringDict == null)
33 {
35 }
36 _stringDict.Add(id, result);
37 }
38 else
39 {
40 if (_strings == null)
41 {
42 _strings = new XmlDictionaryString[Math.Max(id + 1, 16)];
43 }
44 else if (id >= _strings.Length)
45 {
46 XmlDictionaryString[] array = new XmlDictionaryString[Math.Min(Math.Max(id + 1, _strings.Length * 2), 2048)];
49 }
50 _strings[id] = result;
51 }
52 return result;
53 }
54
55 public bool TryLookup(int key, [NotNullWhen(true)] out XmlDictionaryString? result)
56 {
57 if (_strings != null && key >= 0 && key < _strings.Length)
58 {
59 result = _strings[key];
60 return result != null;
61 }
62 if (key >= 2048 && _stringDict != null)
63 {
64 return _stringDict.TryGetValue(key, out result);
65 }
66 result = null;
67 return false;
68 }
69
70 public bool TryLookup(string value, [NotNullWhen(true)] out XmlDictionaryString? result)
71 {
72 if (value == null)
73 {
75 }
76 if (_strings != null)
77 {
78 for (int i = 0; i < _strings.Length; i++)
79 {
81 if (xmlDictionaryString != null && xmlDictionaryString.Value == value)
82 {
83 result = xmlDictionaryString;
84 return true;
85 }
86 }
87 }
88 if (_stringDict != null)
89 {
91 {
92 if (value2.Value == value)
93 {
94 result = value2;
95 return true;
96 }
97 }
98 }
99 result = null;
100 return false;
101 }
102
104 {
105 if (value == null)
106 {
108 }
109 if (value.Dictionary != this)
110 {
111 result = null;
112 return false;
113 }
114 result = value;
115 return true;
116 }
117
118 public void Clear()
119 {
120 if (_strings != null)
121 {
123 }
124 if (_stringDict != null)
125 {
127 }
128 }
129}
static unsafe void Clear(Array array)
Definition Array.cs:755
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void Add(TKey key, TValue value)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static string XmlIDDefined
Definition SR.cs:410
static string XmlInvalidID
Definition SR.cs:432
Definition SR.cs:7
XmlDictionaryString Add(int id, string value)
Dictionary< int, XmlDictionaryString > _stringDict
bool TryLookup(int key, [NotNullWhen(true)] out XmlDictionaryString? result)
bool TryLookup(XmlDictionaryString value, [NotNullWhen(true)] out XmlDictionaryString? result)
bool TryLookup(string value, [NotNullWhen(true)] out XmlDictionaryString? result)