Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DateTimeStorage.cs
Go to the documentation of this file.
3using System.Xml;
4
5namespace System.Data.Common;
6
7internal sealed class DateTimeStorage : DataStorage
8{
9 private static readonly DateTime s_defaultValue = DateTime.MinValue;
10
11 private DateTime[] _values;
12
17
18 public override object Aggregate(int[] records, AggregateType kind)
19 {
20 bool flag = false;
21 try
22 {
23 switch (kind)
24 {
25 case AggregateType.Min:
26 {
28 foreach (int num3 in records)
29 {
30 if (HasValue(num3))
31 {
33 flag = true;
34 }
35 }
36 if (flag)
37 {
38 return dateTime2;
39 }
40 return _nullValue;
41 }
42 case AggregateType.Max:
43 {
45 foreach (int num2 in records)
46 {
47 if (HasValue(num2))
48 {
50 flag = true;
51 }
52 }
53 if (flag)
54 {
55 return dateTime;
56 }
57 return _nullValue;
58 }
59 case AggregateType.First:
60 if (records.Length != 0)
61 {
62 return _values[records[0]];
63 }
64 return null;
65 case AggregateType.Count:
66 {
67 int num = 0;
68 for (int i = 0; i < records.Length; i++)
69 {
70 if (HasValue(records[i]))
71 {
72 num++;
73 }
74 }
75 return num;
76 }
77 }
78 }
79 catch (OverflowException)
80 {
82 }
84 }
85
86 public override int Compare(int recordNo1, int recordNo2)
87 {
91 {
93 if (num != 0)
94 {
95 return num;
96 }
97 }
99 }
100
101 public override int CompareValueTo(int recordNo, object value)
102 {
103 if (_nullValue == value)
104 {
105 if (!HasValue(recordNo))
106 {
107 return 0;
108 }
109 return 1;
110 }
113 {
114 return -1;
115 }
117 }
118
119 public override object ConvertValue(object value)
120 {
121 if (_nullValue != value)
122 {
123 value = ((value == null) ? _nullValue : ((object)((IConvertible)value).ToDateTime(base.FormatProvider)));
124 }
125 return value;
126 }
127
128 public override void Copy(int recordNo1, int recordNo2)
129 {
132 }
133
134 public override object Get(int record)
135 {
138 {
139 return dateTime;
140 }
141 return _nullValue;
142 }
143
144 public override void Set(int record, object value)
145 {
146 if (_nullValue == value)
147 {
149 SetNullBit(record, flag: true);
150 return;
151 }
152 DateTime dateTime = ((IConvertible)value).ToDateTime(base.FormatProvider);
154 switch (base.DateTimeMode)
155 {
156 case DataSetDateTime.Utc:
157 dateTime2 = ((dateTime.Kind != DateTimeKind.Utc) ? ((dateTime.Kind != DateTimeKind.Local) ? DateTime.SpecifyKind(dateTime, DateTimeKind.Utc) : dateTime.ToUniversalTime()) : dateTime);
158 break;
159 case DataSetDateTime.Local:
160 dateTime2 = ((dateTime.Kind != DateTimeKind.Local) ? ((dateTime.Kind != DateTimeKind.Utc) ? DateTime.SpecifyKind(dateTime, DateTimeKind.Local) : dateTime.ToLocalTime()) : dateTime);
161 break;
162 case DataSetDateTime.Unspecified:
163 case DataSetDateTime.UnspecifiedLocal:
165 break;
166 default:
167 throw ExceptionBuilder.InvalidDateTimeMode(base.DateTimeMode);
168 }
170 SetNullBit(record, flag: false);
171 }
172
173 public override void SetCapacity(int capacity)
174 {
176 if (_values != null)
177 {
179 }
180 _values = array;
181 base.SetCapacity(capacity);
182 }
183
184 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
185 public override object ConvertXmlToObject(string s)
186 {
187 if (base.DateTimeMode == DataSetDateTime.UnspecifiedLocal)
188 {
190 }
192 }
193
194 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
195 public override string ConvertObjectToXml(object value)
196 {
197 if (base.DateTimeMode == DataSetDateTime.UnspecifiedLocal)
198 {
200 }
202 }
203
204 protected override object GetEmptyStorage(int recordCount)
205 {
206 return new DateTime[recordCount];
207 }
208
209 protected override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
210 {
212 bool flag = !HasValue(record);
213 if (flag || (base.DateTimeMode & DataSetDateTime.Local) == 0)
214 {
216 }
217 else
218 {
220 }
221 nullbits.Set(storeIndex, flag);
222 }
223
224 protected override void SetStorage(object store, BitArray nullbits)
225 {
228 if (base.DateTimeMode == DataSetDateTime.UnspecifiedLocal)
229 {
230 for (int i = 0; i < _values.Length; i++)
231 {
232 if (HasValue(i))
233 {
234 _values[i] = DateTime.SpecifyKind(_values[i].ToLocalTime(), DateTimeKind.Unspecified);
235 }
236 }
237 }
238 else
239 {
240 if (base.DateTimeMode != DataSetDateTime.Local)
241 {
242 return;
243 }
244 for (int j = 0; j < _values.Length; j++)
245 {
246 if (HasValue(j))
247 {
249 }
250 }
251 }
252 }
253}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void SetNullStorage(BitArray nullbits)
int CompareBits(int recordNo1, int recordNo2)
bool HasValue(int recordNo)
void SetNullBit(int recordNo, bool flag)
void CopyBits(int srcRecordNo, int dstRecordNo)
override string ConvertObjectToXml(object value)
override void SetStorage(object store, BitArray nullbits)
override object ConvertXmlToObject(string s)
override int CompareValueTo(int recordNo, object value)
override void Set(int record, object value)
override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
static readonly DateTime s_defaultValue
override int Compare(int recordNo1, int recordNo2)
override object ConvertValue(object value)
override object Get(int record)
override void SetCapacity(int capacity)
override object GetEmptyStorage(int recordCount)
override void Copy(int recordNo1, int recordNo2)
override object Aggregate(int[] records, AggregateType kind)
static Exception AggregateException(AggregateType aggregateType, Type type)
static Exception InvalidDateTimeMode(DataSetDateTime mode)
static Exception Overflow(Type type)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static string ToString(bool value)
static DateTime ToDateTime(string s)
static readonly DateTime MaxValue
Definition DateTime.cs:37
static readonly DateTime MinValue
Definition DateTime.cs:35
DateTime ToUniversalTime()
Definition DateTime.cs:1134
static int Compare(DateTime t1, DateTime t2)
Definition DateTime.cs:546
DateTime IConvertible. ToDateTime(IFormatProvider provider)
Definition DateTime.cs:1355
DateTime ToLocalTime()
Definition DateTime.cs:1068
static DateTime SpecifyKind(DateTime value, DateTimeKind kind)
Definition DateTime.cs:756