Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
BigIntegerStorage.cs
Go to the documentation of this file.
5
6namespace System.Data.Common;
7
8internal sealed class BigIntegerStorage : DataStorage
9{
11
13 : base(column, typeof(BigInteger), BigInteger.Zero, StorageType.BigInteger)
14 {
15 }
16
17 public override object Aggregate(int[] records, AggregateType kind)
18 {
20 }
21
22 public override int Compare(int recordNo1, int recordNo2)
23 {
24 BigInteger bigInteger = _values[recordNo1];
25 BigInteger other = _values[recordNo2];
26 if (bigInteger.IsZero || other.IsZero)
27 {
28 int num = CompareBits(recordNo1, recordNo2);
29 if (num != 0)
30 {
31 return num;
32 }
33 }
34 return bigInteger.CompareTo(other);
35 }
36
37 public override int CompareValueTo(int recordNo, object value)
38 {
39 if (_nullValue == value)
40 {
41 if (!HasValue(recordNo))
42 {
43 return 0;
44 }
45 return 1;
46 }
47 BigInteger bigInteger = _values[recordNo];
48 if (bigInteger.IsZero && !HasValue(recordNo))
49 {
50 return -1;
51 }
52 return bigInteger.CompareTo((BigInteger)value);
53 }
54
55 internal static BigInteger ConvertToBigInteger(object value, IFormatProvider formatProvider)
56 {
57 if (value.GetType() == typeof(BigInteger))
58 {
59 return (BigInteger)value;
60 }
61 if (value.GetType() == typeof(string))
62 {
63 return BigInteger.Parse((string)value, formatProvider);
64 }
65 if (value.GetType() == typeof(long))
66 {
67 return (long)value;
68 }
69 if (value.GetType() == typeof(int))
70 {
71 return (int)value;
72 }
73 if (value.GetType() == typeof(short))
74 {
75 return (short)value;
76 }
77 if (value.GetType() == typeof(sbyte))
78 {
79 return (sbyte)value;
80 }
81 if (value.GetType() == typeof(ulong))
82 {
83 return (ulong)value;
84 }
85 if (value.GetType() == typeof(uint))
86 {
87 return (uint)value;
88 }
89 if (value.GetType() == typeof(ushort))
90 {
91 return (ushort)value;
92 }
93 if (value.GetType() == typeof(byte))
94 {
95 return (byte)value;
96 }
97 throw ExceptionBuilder.ConvertFailed(value.GetType(), typeof(BigInteger));
98 }
99
100 internal static object ConvertFromBigInteger(BigInteger value, Type type, IFormatProvider formatProvider)
101 {
102 if (type == typeof(string))
103 {
104 return value.ToString("D", formatProvider);
105 }
106 if (type == typeof(sbyte))
107 {
108 return (sbyte)value;
109 }
110 if (type == typeof(short))
111 {
112 return (short)value;
113 }
114 if (type == typeof(int))
115 {
116 return (int)value;
117 }
118 if (type == typeof(long))
119 {
120 return (long)value;
121 }
122 if (type == typeof(byte))
123 {
124 return (byte)value;
125 }
126 if (type == typeof(ushort))
127 {
128 return (ushort)value;
129 }
130 if (type == typeof(uint))
131 {
132 return (uint)value;
133 }
134 if (type == typeof(ulong))
135 {
136 return (ulong)value;
137 }
138 if (type == typeof(float))
139 {
140 return (float)value;
141 }
142 if (type == typeof(double))
143 {
144 return (double)value;
145 }
146 if (type == typeof(decimal))
147 {
148 return (decimal)value;
149 }
150 if (type == typeof(BigInteger))
151 {
152 return value;
153 }
155 }
156
157 public override object ConvertValue(object value)
158 {
159 if (_nullValue != value)
160 {
161 value = ((value == null) ? _nullValue : ((object)ConvertToBigInteger(value, base.FormatProvider)));
162 }
163 return value;
164 }
165
166 public override void Copy(int recordNo1, int recordNo2)
167 {
168 CopyBits(recordNo1, recordNo2);
169 _values[recordNo2] = _values[recordNo1];
170 }
171
172 public override object Get(int record)
173 {
174 BigInteger bigInteger = _values[record];
175 if (!bigInteger.IsZero)
176 {
177 return bigInteger;
178 }
179 return GetBits(record);
180 }
181
182 public override void Set(int record, object value)
183 {
184 if (_nullValue == value)
185 {
186 _values[record] = BigInteger.Zero;
187 SetNullBit(record, flag: true);
188 }
189 else
190 {
191 _values[record] = ConvertToBigInteger(value, base.FormatProvider);
192 SetNullBit(record, flag: false);
193 }
194 }
195
196 public override void SetCapacity(int capacity)
197 {
199 if (_values != null)
200 {
202 }
203 _values = array;
204 base.SetCapacity(capacity);
205 }
206
207 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
208 public override object ConvertXmlToObject(string s)
209 {
211 }
212
213 [RequiresUnreferencedCode("Members from serialized types may be trimmed if not referenced directly.")]
214 public override string ConvertObjectToXml(object value)
215 {
216 return ((BigInteger)value).ToString("D", CultureInfo.InvariantCulture);
217 }
218
219 protected override object GetEmptyStorage(int recordCount)
220 {
221 return new BigInteger[recordCount];
222 }
223
224 protected override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
225 {
226 BigInteger[] array = (BigInteger[])store;
227 array[storeIndex] = _values[record];
228 nullbits.Set(storeIndex, !HasValue(record));
229 }
230
231 protected override void SetStorage(object store, BitArray nullbits)
232 {
233 _values = (BigInteger[])store;
234 SetNullStorage(nullbits);
235 }
236}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void Set(int index, bool value)
Definition BitArray.cs:326
override int CompareValueTo(int recordNo, object value)
override object ConvertValue(object value)
override string ConvertObjectToXml(object value)
override void Copy(int recordNo1, int recordNo2)
static object ConvertFromBigInteger(BigInteger value, Type type, IFormatProvider formatProvider)
override int Compare(int recordNo1, int recordNo2)
override object ConvertXmlToObject(string s)
override object Aggregate(int[] records, AggregateType kind)
override void CopyValue(int record, object store, BitArray nullbits, int storeIndex)
override void SetCapacity(int capacity)
override void SetStorage(object store, BitArray nullbits)
override object GetEmptyStorage(int recordCount)
static BigInteger ConvertToBigInteger(object value, IFormatProvider formatProvider)
override void Set(int record, object value)
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)
object GetBits(int recordNo)
static Exception AggregateException(AggregateType aggregateType, Type type)
static Exception ConvertFailed(Type type1, Type type2)
static CultureInfo InvariantCulture
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static BigInteger Parse(string value)
static BigInteger Zero
Definition BigInteger.cs:32
int CompareTo(long other)