Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DataRecordInternal.cs
Go to the documentation of this file.
4
5namespace System.Data.Common;
6
8{
9 private readonly SchemaInfo[] _schemaInfo;
10
11 private readonly object[] _values;
12
14
16
17 public override int FieldCount => _schemaInfo.Length;
18
19 public override object this[int i] => GetValue(i);
20
21 public override object this[string name] => GetValue(GetOrdinal(name));
22
23 internal DataRecordInternal(SchemaInfo[] schemaInfo, object[] values, PropertyDescriptorCollection descriptors, FieldNameLookup fieldNameLookup)
24 {
25 _schemaInfo = schemaInfo;
27 _propertyDescriptors = descriptors;
28 _fieldNameLookup = fieldNameLookup;
29 }
30
31 public override int GetValues(object[] values)
32 {
33 if (values == null)
34 {
35 throw ADP.ArgumentNull("values");
36 }
37 int num = ((values.Length < _schemaInfo.Length) ? values.Length : _schemaInfo.Length);
38 for (int i = 0; i < num; i++)
39 {
40 values[i] = _values[i];
41 }
42 return num;
43 }
44
45 public override string GetName(int i)
46 {
47 return _schemaInfo[i].name;
48 }
49
50 public override object GetValue(int i)
51 {
52 return _values[i];
53 }
54
55 public override string GetDataTypeName(int i)
56 {
57 return _schemaInfo[i].typeName;
58 }
59
60 [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)]
61 public override Type GetFieldType(int i)
62 {
63 return _schemaInfo[i].type;
64 }
65
66 public override int GetOrdinal(string name)
67 {
68 return _fieldNameLookup.GetOrdinal(name);
69 }
70
71 public override bool GetBoolean(int i)
72 {
73 return (bool)_values[i];
74 }
75
76 public override byte GetByte(int i)
77 {
78 return (byte)_values[i];
79 }
80
81 public override long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length)
82 {
83 int num = 0;
84 byte[] array = (byte[])_values[i];
85 num = array.Length;
86 if (dataIndex > int.MaxValue)
87 {
88 throw ADP.InvalidSourceBufferIndex(num, dataIndex, "dataIndex");
89 }
90 int num2 = (int)dataIndex;
91 if (buffer == null)
92 {
93 return num;
94 }
95 try
96 {
97 if (num2 < num)
98 {
99 num = ((num2 + length <= num) ? length : (num - num2));
100 }
101 Array.Copy(array, num2, buffer, bufferIndex, num);
102 }
103 catch (Exception e) when (ADP.IsCatchableExceptionType(e))
104 {
105 num = array.Length;
106 if (length < 0)
107 {
109 }
110 if (bufferIndex < 0 || bufferIndex >= buffer.Length)
111 {
112 throw ADP.InvalidDestinationBufferIndex(length, bufferIndex, "bufferIndex");
113 }
114 if (dataIndex < 0 || dataIndex >= num)
115 {
116 throw ADP.InvalidSourceBufferIndex(length, dataIndex, "dataIndex");
117 }
118 if (num + bufferIndex > buffer.Length)
119 {
120 throw ADP.InvalidBufferSizeOrIndex(num, bufferIndex);
121 }
122 }
123 return num;
124 }
125
126 public override char GetChar(int i)
127 {
128 return ((string)_values[i])[0];
129 }
130
131 public override long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length)
132 {
133 string text = (string)_values[i];
134 char[] array = text.ToCharArray();
135 int num = array.Length;
136 if (dataIndex > int.MaxValue)
137 {
138 throw ADP.InvalidSourceBufferIndex(num, dataIndex, "dataIndex");
139 }
140 int num2 = (int)dataIndex;
141 if (buffer == null)
142 {
143 return num;
144 }
145 try
146 {
147 if (num2 < num)
148 {
149 num = ((num2 + length <= num) ? length : (num - num2));
150 }
151 Array.Copy(array, num2, buffer, bufferIndex, num);
152 }
153 catch (Exception e) when (ADP.IsCatchableExceptionType(e))
154 {
155 num = array.Length;
156 if (length < 0)
157 {
159 }
160 if (bufferIndex < 0 || bufferIndex >= buffer.Length)
161 {
162 throw ADP.InvalidDestinationBufferIndex(buffer.Length, bufferIndex, "bufferIndex");
163 }
164 if (num2 < 0 || num2 >= num)
165 {
166 throw ADP.InvalidSourceBufferIndex(num, dataIndex, "dataIndex");
167 }
168 if (num + bufferIndex > buffer.Length)
169 {
170 throw ADP.InvalidBufferSizeOrIndex(num, bufferIndex);
171 }
172 }
173 return num;
174 }
175
176 public override Guid GetGuid(int i)
177 {
178 return (Guid)_values[i];
179 }
180
181 public override short GetInt16(int i)
182 {
183 return (short)_values[i];
184 }
185
186 public override int GetInt32(int i)
187 {
188 return (int)_values[i];
189 }
190
191 public override long GetInt64(int i)
192 {
193 return (long)_values[i];
194 }
195
196 public override float GetFloat(int i)
197 {
198 return (float)_values[i];
199 }
200
201 public override double GetDouble(int i)
202 {
203 return (double)_values[i];
204 }
205
206 public override string GetString(int i)
207 {
208 return (string)_values[i];
209 }
210
211 public override decimal GetDecimal(int i)
212 {
213 return (decimal)_values[i];
214 }
215
216 public override DateTime GetDateTime(int i)
217 {
218 return (DateTime)_values[i];
219 }
220
221 public override bool IsDBNull(int i)
222 {
223 object obj = _values[i];
224 if (obj != null)
225 {
226 return Convert.IsDBNull(obj);
227 }
228 return true;
229 }
230
235
237 {
238 return null;
239 }
240
242 {
243 return null;
244 }
245
246 [RequiresUnreferencedCode("Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All.")]
248 {
249 return null;
250 }
251
252 [RequiresUnreferencedCode("The built-in EventDescriptor implementation uses Reflection which requires unreferenced code.")]
257
258 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
263
264 [RequiresUnreferencedCode("Editors registered in TypeDescriptor.AddEditorTable may be trimmed.")]
265 object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
266 {
267 return null;
268 }
269
274
275 [RequiresUnreferencedCode("The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
280
281 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered.")]
283 {
284 return ((ICustomTypeDescriptor)this).GetProperties((Attribute[]?)null);
285 }
286
287 [RequiresUnreferencedCode("PropertyDescriptor's PropertyType cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
296
298 {
299 return this;
300 }
301}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static bool IsDBNull([NotNullWhen(true)] object? value)
Definition Convert.cs:215
static IndexOutOfRangeException InvalidBufferSizeOrIndex(int numBytes, int bufferIndex)
Definition ADP.cs:937
static ArgumentNullException ArgumentNull(string parameter)
Definition ADP.cs:699
static ArgumentOutOfRangeException InvalidSourceBufferIndex(int maxLen, long srcOffset, string parameterName)
Definition ADP.cs:927
static ArgumentOutOfRangeException InvalidDestinationBufferIndex(int maxLen, int dstOffset, string parameterName)
Definition ADP.cs:932
static bool IsCatchableExceptionType(Exception e)
Definition ADP.cs:790
static Exception InvalidDataLength(long length)
Definition ADP.cs:942
override long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length)
DataRecordInternal(SchemaInfo[] schemaInfo, object[] values, PropertyDescriptorCollection descriptors, FieldNameLookup fieldNameLookup)
override long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length)
readonly FieldNameLookup _fieldNameLookup
PropertyDescriptorCollection _propertyDescriptors
override int GetValues(object[] values)
object? GetEditor(Type editorBaseType)
object? GetPropertyOwner(PropertyDescriptor? pd)
PropertyDescriptorCollection GetProperties()
EventDescriptorCollection GetEvents()