Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
KeySequence.cs
Go to the documentation of this file.
2using System.Text;
3
4namespace System.Xml.Schema;
5
6internal sealed class KeySequence
7{
8 private readonly TypedObject[] _ks;
9
10 private readonly int _dim;
11
12 private int _hashcode = -1;
13
14 private readonly int _posline;
15
16 private readonly int _poscol;
17
18 public int PosLine => _posline;
19
20 public int PosCol => _poscol;
21
22 public object this[int index]
23 {
24 get
25 {
26 return _ks[index];
27 }
28 set
29 {
31 }
32 }
33
34 internal KeySequence(int dim, int line, int col)
35 {
36 _dim = dim;
37 _ks = new TypedObject[dim];
38 _posline = line;
39 _poscol = col;
40 }
41
42 internal bool IsQualified()
43 {
44 for (int i = 0; i < _ks.Length; i++)
45 {
46 if (_ks[i] == null || _ks[i].Value == null)
47 {
48 return false;
49 }
50 }
51 return true;
52 }
53
54 public override int GetHashCode()
55 {
56 if (_hashcode != -1)
57 {
58 return _hashcode;
59 }
60 _hashcode = 0;
61 for (int i = 0; i < _ks.Length; i++)
62 {
63 _ks[i].SetDecimal();
64 if (_ks[i].IsDecimal)
65 {
66 for (int j = 0; j < _ks[i].Dim; j++)
67 {
68 _hashcode += _ks[i].Dvalue[j].GetHashCode();
69 }
70 }
71 else if (_ks[i].Value is Array array)
72 {
74 {
75 for (int k = 0; k < array2.Length; k++)
76 {
77 _hashcode += ((XmlAtomicValue)array2.GetValue(k)).TypedValue.GetHashCode();
78 }
79 }
80 else
81 {
82 for (int l = 0; l < ((Array)_ks[i].Value).Length; l++)
83 {
84 _hashcode += ((Array)_ks[i].Value).GetValue(l).GetHashCode();
85 }
86 }
87 }
88 else
89 {
90 _hashcode += _ks[i].Value.GetHashCode();
91 }
92 }
93 return _hashcode;
94 }
95
96 public override bool Equals([NotNullWhen(true)] object other)
97 {
99 {
100 for (int i = 0; i < _ks.Length; i++)
101 {
102 if (!_ks[i].Equals(keySequence._ks[i]))
103 {
104 return false;
105 }
106 }
107 return true;
108 }
109 return false;
110 }
111
112 public override string ToString()
113 {
115 stringBuilder.Append(_ks[0].ToString());
116 for (int i = 1; i < _ks.Length; i++)
117 {
118 stringBuilder.Append(' ');
119 stringBuilder.Append(_ks[i].ToString());
120 }
121 return stringBuilder.ToString();
122 }
123}
KeySequence(int dim, int line, int col)
override bool Equals([NotNullWhen(true)] object other)
readonly TypedObject[] _ks
Definition KeySequence.cs:8