Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Add()

XmlDictionaryString System.Xml.XmlBinaryReaderSession.Add ( int id,
string value )
inline

Definition at line 15 of file XmlBinaryReaderSession.cs.

16 {
17 if (id < 0)
18 {
19 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("id", System.SR.XmlInvalidID));
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)];
47 Array.Copy(_strings, array, _strings.Length);
49 }
50 _strings[id] = result;
51 }
52 return result;
53 }
void Add(TKey key, TValue value)
static string XmlIDDefined
Definition SR.cs:410
static string XmlInvalidID
Definition SR.cs:432
Definition SR.cs:7
Dictionary< int, XmlDictionaryString > _stringDict
bool TryLookup(int key, [NotNullWhen(true)] out XmlDictionaryString? result)

References System.Xml.XmlBinaryReaderSession._stringDict, System.Xml.XmlBinaryReaderSession._strings, System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.array, System.Array.Copy(), System.Xml.Dictionary, System.Math.Max(), System.Math.Min(), System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(), System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(), System.Xml.XmlBinaryReaderSession.TryLookup(), System.value, System.SR.XmlIDDefined, and System.SR.XmlInvalidID.