Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StringStorage.cs
Go to the documentation of this file.
3
4namespace System.Data.Common;
5
6internal sealed class StringStorage : DataStorage
7{
8 private string[] _values;
9
11 : base(column, typeof(string), string.Empty, StorageType.String)
12 {
13 }
14
15 public override object Aggregate(int[] recordNos, AggregateType kind)
16 {
17 switch (kind)
18 {
19 case AggregateType.Min:
20 {
21 int num3 = -1;
22 int i;
23 for (i = 0; i < recordNos.Length; i++)
24 {
25 if (!IsNull(recordNos[i]))
26 {
27 num3 = recordNos[i];
28 break;
29 }
30 }
31 if (num3 >= 0)
32 {
33 for (i++; i < recordNos.Length; i++)
34 {
35 if (!IsNull(recordNos[i]) && Compare(num3, recordNos[i]) > 0)
36 {
37 num3 = recordNos[i];
38 }
39 }
40 return Get(num3);
41 }
42 return _nullValue;
43 }
44 case AggregateType.Max:
45 {
46 int num2 = -1;
47 int i;
48 for (i = 0; i < recordNos.Length; i++)
49 {
50 if (!IsNull(recordNos[i]))
51 {
52 num2 = recordNos[i];
53 break;
54 }
55 }
56 if (num2 >= 0)
57 {
58 for (i++; i < recordNos.Length; i++)
59 {
60 if (Compare(num2, recordNos[i]) < 0)
61 {
62 num2 = recordNos[i];
63 }
64 }
65 return Get(num2);
66 }
67 return _nullValue;
68 }
69 case AggregateType.Count:
70 {
71 int num = 0;
72 for (int i = 0; i < recordNos.Length; i++)
73 {
74 object obj = _values[recordNos[i]];
75 if (obj != null)
76 {
77 num++;
78 }
79 }
80 return num;
81 }
82 default:
84 }
85 }
86
87 public override int Compare(int recordNo1, int recordNo2)
88 {
89 string text = _values[recordNo1];
90 string text2 = _values[recordNo2];
91 if ((object)text == text2)
92 {
93 return 0;
94 }
95 if (text == null)
96 {
97 return -1;
98 }
99 if (text2 == null)
100 {
101 return 1;
102 }
103 return _table.Compare(text, text2);
104 }
105
106 public override int CompareValueTo(int recordNo, object value)
107 {
108 string text = _values[recordNo];
109 if (text == null)
110 {
111 if (_nullValue == value)
112 {
113 return 0;
114 }
115 return -1;
116 }
117 if (_nullValue == value)
118 {
119 return 1;
120 }
121 return _table.Compare(text, (string)value);
122 }
123
124 public override object ConvertValue(object value)
125 {
126 if (_nullValue != value)
127 {
128 value = ((value == null) ? _nullValue : value.ToString());
129 }
130 return value;
131 }
132
133 public override void Copy(int recordNo1, int recordNo2)
134 {
135 _values[recordNo2] = _values[recordNo1];
136 }
137
138 public override object Get(int recordNo)
139 {
140 string text = _values[recordNo];
141 if (text != null)
142 {
143 return text;
144 }
145 return _nullValue;
146 }
147
148 public override int GetStringLength(int record)
149 {
150 return _values[record]?.Length ?? 0;
151 }
152
153 public override bool IsNull(int record)
154 {
155 return _values[record] == null;
156 }
157
158 public override void Set(int record, object value)
159 {
160 if (_nullValue == value)
161 {
162 _values[record] = null;
163 }
164 else
165 {
166 _values[record] = value.ToString();
167 }
168 }
169
170 public override void SetCapacity(int capacity)
171 {
172 string[] array = new string[capacity];
173 if (_values != null)
174 {
176 }
177 _values = array;
178 }
179
180 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
181 public override object ConvertXmlToObject(string s)
182 {
183 return s;
184 }
185
186 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
187 public override string ConvertObjectToXml(object value)
188 {
189 return (string)value;
190 }
191
192 protected override object GetEmptyStorage(int recordCount)
193 {
194 return new string[recordCount];
195 }
196
197 protected override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
198 {
199 string[] array = (string[])store;
200 array[storeIndex] = _values[record];
201 nullbits.Set(storeIndex, IsNull(record));
202 }
203
204 protected override void SetStorage(object store, BitArray nullbits)
205 {
206 _values = (string[])store;
207 }
208}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void Set(int index, bool value)
Definition BitArray.cs:326
readonly DataTable _table
override void Set(int record, object value)
override int CompareValueTo(int recordNo, object value)
override object Aggregate(int[] recordNos, AggregateType kind)
override object GetEmptyStorage(int recordCount)
override void SetCapacity(int capacity)
override string ConvertObjectToXml(object value)
override bool IsNull(int record)
override void Copy(int recordNo1, int recordNo2)
override int GetStringLength(int record)
override int Compare(int recordNo1, int recordNo2)
override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
override void SetStorage(object store, BitArray nullbits)
override object ConvertXmlToObject(string s)
override object Get(int recordNo)
override object ConvertValue(object value)
int Compare(string s1, string s2)
static Exception AggregateException(AggregateType aggregateType, Type type)
static byte Min(byte val1, byte val2)
Definition Math.cs:912