Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DecodeObjects()

static unsafe void System.Diagnostics.Tracing.EventSource.DecodeObjects ( object[] decodedObjects,
Type[] parameterTypes,
EventData * data )
inlinestaticprivateinherited

Definition at line 1225 of file EventSource.cs.

1226 {
1227 object obj;
1228 for (int i = 0; i < decodedObjects.Length; decodedObjects[i] = obj, i++, data++)
1229 {
1230 IntPtr dataPointer = data->DataPointer;
1232 if (!(type == typeof(string)))
1233 {
1234 if (type == typeof(int))
1235 {
1236 obj = *(int*)(void*)dataPointer;
1237 continue;
1238 }
1239 TypeCode typeCode = Type.GetTypeCode(type);
1240 int size = data->Size;
1241 if (size == 4)
1242 {
1243 if ((uint)(typeCode - 5) <= 4u)
1244 {
1245 obj = *(int*)(void*)dataPointer;
1246 continue;
1247 }
1248 if (typeCode == TypeCode.UInt32)
1249 {
1250 obj = *(uint*)(void*)dataPointer;
1251 continue;
1252 }
1253 if (typeCode == TypeCode.Single)
1254 {
1255 obj = *(float*)(void*)dataPointer;
1256 continue;
1257 }
1258 if (typeCode == TypeCode.Boolean)
1259 {
1260 obj = *(int*)(void*)dataPointer == 1;
1261 continue;
1262 }
1263 if (type == typeof(byte[]))
1264 {
1265 data++;
1266 goto IL_0256;
1267 }
1268 if (IntPtr.Size != 4)
1269 {
1270 goto IL_0244;
1271 }
1272 }
1273 if (size <= 2)
1274 {
1275 switch (typeCode)
1276 {
1277 case TypeCode.Byte:
1278 obj = *(byte*)(void*)dataPointer;
1279 continue;
1280 case TypeCode.SByte:
1281 obj = *(sbyte*)(void*)dataPointer;
1282 continue;
1283 case TypeCode.Int16:
1284 obj = *(short*)(void*)dataPointer;
1285 continue;
1286 case TypeCode.UInt16:
1287 obj = *(ushort*)(void*)dataPointer;
1288 continue;
1289 case TypeCode.Char:
1290 obj = *(char*)(void*)dataPointer;
1291 continue;
1292 }
1293 }
1294 else if (size == 8)
1295 {
1296 switch (typeCode)
1297 {
1298 case TypeCode.Int64:
1299 obj = *(long*)(void*)dataPointer;
1300 continue;
1301 case TypeCode.UInt64:
1302 obj = *(ulong*)(void*)dataPointer;
1303 continue;
1304 case TypeCode.Double:
1305 obj = *(double*)(void*)dataPointer;
1306 continue;
1307 case TypeCode.DateTime:
1308 obj = *(DateTime*)(void*)dataPointer;
1309 continue;
1310 }
1311 _ = IntPtr.Size;
1312 if (type == typeof(IntPtr))
1313 {
1314 obj = *(IntPtr*)(void*)dataPointer;
1315 continue;
1316 }
1317 }
1318 else
1319 {
1320 if (typeCode == TypeCode.Decimal)
1321 {
1322 obj = *(decimal*)(void*)dataPointer;
1323 continue;
1324 }
1325 if (type == typeof(Guid))
1326 {
1327 obj = *(Guid*)(void*)dataPointer;
1328 continue;
1329 }
1330 }
1331 goto IL_0244;
1332 }
1333 goto IL_028a;
1334 IL_0256:
1335 if (data->Size == 0)
1336 {
1337 obj = Array.Empty<byte>();
1338 continue;
1339 }
1340 byte[] array = new byte[data->Size];
1341 Marshal.Copy(data->DataPointer, array, 0, array.Length);
1342 obj = array;
1343 continue;
1344 IL_0244:
1345 if (!(type != typeof(byte*)))
1346 {
1347 goto IL_0256;
1348 }
1349 goto IL_028a;
1350 IL_028a:
1351 obj = ((dataPointer == IntPtr.Zero) ? null : new string((char*)(void*)dataPointer, 0, (data->Size >> 1) - 1));
1352 }
1353 }
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
Definition Marshal.cs:800

References System.array, System.Runtime.InteropServices.Marshal.Copy(), System.Diagnostics.Tracing.EventSource.EventData.DataPointer, System.Type.GetTypeCode(), System.obj, System.Diagnostics.Tracing.EventSource.EventData.Size, System.IntPtr.Size, System.type, and System.IntPtr.Zero.

Referenced by System.Diagnostics.Tracing.EventSource.WriteToAllListeners().