Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CharStorage.cs
Go to the documentation of this file.
3using System.Xml;
4
5namespace System.Data.Common;
6
7internal sealed class CharStorage : DataStorage
8{
9 private char[] _values;
10
12 : base(column, typeof(char), '\0', StorageType.Char)
13 {
14 }
15
16 public override object Aggregate(int[] records, AggregateType kind)
17 {
18 bool flag = false;
19 try
20 {
21 switch (kind)
22 {
23 case AggregateType.Min:
24 {
25 char c2 = '\uffff';
26 foreach (int num2 in records)
27 {
28 if (!IsNull(num2))
29 {
30 c2 = ((_values[num2] < c2) ? _values[num2] : c2);
31 flag = true;
32 }
33 }
34 if (flag)
35 {
36 return c2;
37 }
38 return _nullValue;
39 }
40 case AggregateType.Max:
41 {
42 char c = '\0';
43 foreach (int num in records)
44 {
45 if (!IsNull(num))
46 {
47 c = ((_values[num] > c) ? _values[num] : c);
48 flag = true;
49 }
50 }
51 if (flag)
52 {
53 return c;
54 }
55 return _nullValue;
56 }
57 case AggregateType.First:
58 if (records.Length != 0)
59 {
60 return _values[records[0]];
61 }
62 return null;
63 case AggregateType.Count:
64 return base.Aggregate(records, kind);
65 }
66 }
67 catch (OverflowException)
68 {
69 throw ExprException.Overflow(typeof(char));
70 }
72 }
73
74 public override int Compare(int recordNo1, int recordNo2)
75 {
76 char c = _values[recordNo1];
77 char c2 = _values[recordNo2];
78 if (c == '\0' || c2 == '\0')
79 {
81 if (num != 0)
82 {
83 return num;
84 }
85 }
86 return c.CompareTo(c2);
87 }
88
89 public override int CompareValueTo(int recordNo, object value)
90 {
91 if (_nullValue == value)
92 {
93 if (IsNull(recordNo))
94 {
95 return 0;
96 }
97 return 1;
98 }
99 char c = _values[recordNo];
100 if (c == '\0' && IsNull(recordNo))
101 {
102 return -1;
103 }
104 return c.CompareTo((char)value);
105 }
106
107 public override object ConvertValue(object value)
108 {
109 if (_nullValue != value)
110 {
111 value = ((value == null) ? _nullValue : ((object)((IConvertible)value).ToChar(base.FormatProvider)));
112 }
113 return value;
114 }
115
116 public override void Copy(int recordNo1, int recordNo2)
117 {
120 }
121
122 public override object Get(int record)
123 {
124 char c = _values[record];
125 if (c != 0)
126 {
127 return c;
128 }
129 return GetBits(record);
130 }
131
132 public override void Set(int record, object value)
133 {
134 if (_nullValue == value)
135 {
136 _values[record] = '\0';
137 SetNullBit(record, flag: true);
138 return;
139 }
140 char c = ((IConvertible)value).ToChar(base.FormatProvider);
141 if (c < '\ud800' || c > '\udfff')
142 {
143 switch (c)
144 {
145 case '\t':
146 case '\n':
147 case '\r':
148 break;
149 default:
150 _values[record] = c;
151 SetNullBit(record, flag: false);
152 return;
153 }
154 }
156 }
157
158 public override void SetCapacity(int capacity)
159 {
160 char[] array = new char[capacity];
161 if (_values != null)
162 {
164 }
165 _values = array;
166 base.SetCapacity(capacity);
167 }
168
169 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
170 public override object ConvertXmlToObject(string s)
171 {
172 return XmlConvert.ToChar(s);
173 }
174
175 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
176 public override string ConvertObjectToXml(object value)
177 {
178 return XmlConvert.ToString((char)value);
179 }
180
181 protected override object GetEmptyStorage(int recordCount)
182 {
183 return new char[recordCount];
184 }
185
186 protected override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
187 {
188 char[] array = (char[])store;
191 }
192
193 protected override void SetStorage(object store, BitArray nullbits)
194 {
195 _values = (char[])store;
197 }
198}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
override void SetCapacity(int capacity)
override void Copy(int recordNo1, int recordNo2)
override int Compare(int recordNo1, int recordNo2)
override void SetStorage(object store, BitArray nullbits)
override object ConvertValue(object value)
override object Get(int record)
override object Aggregate(int[] records, AggregateType kind)
override int CompareValueTo(int recordNo, object value)
override string ConvertObjectToXml(object value)
CharStorage(DataColumn column)
override object GetEmptyStorage(int recordCount)
override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
override void Set(int record, object value)
override object ConvertXmlToObject(string s)
void SetNullStorage(BitArray nullbits)
int CompareBits(int recordNo1, int recordNo2)
void SetNullBit(int recordNo, bool flag)
void CopyBits(int srcRecordNo, int dstRecordNo)
object GetBits(int recordNo)
static Exception AggregateException(AggregateType aggregateType, Type type)
static Exception ProblematicChars(char charValue)
static Exception Overflow(Type type)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static string ToString(bool value)
static char ToChar(string s)