private GXDebugItem[] ReadItems(GXDebugStream stream, out Guid sessionGuid, out GXDebugGenId genId, IList <GXDebugError> errors) { sessionGuid = Guid.Empty; genId = GXDebugGenId.INVALID; stream.InitializeNewBlock(); if (!FindEscape(stream, GXDebugStream.ESCAPE.PROLOG, errors)) { return(null); } short versionAndGenId = stream.ReadVLUShort(); genId = (GXDebugGenId)(versionAndGenId & 0xF); short version = (short)(versionAndGenId >> 4); if (version != GXDebugManager.GXDEBUG_VERSION) { errors.Add(new GXDebugError(stream.Position, $"Cannot parse version { version } blocks")); FindEscape(stream, GXDebugStream.ESCAPE.EPILOG, errors); return(new GXDebugItem[0]); } int itemCount = stream.ReadVLUInt(); if (itemCount == 0) { errors.Add(new GXDebugError(stream.Position, $"Invalid block. Item count = 0")); FindEscape(stream, GXDebugStream.ESCAPE.EPILOG, errors); return(new GXDebugItem[0]); } byte[] guid = new byte[16]; sessionGuid = new Guid(stream.ReadFully(guid)); GXDebugItem[] items = new GXDebugItem[itemCount]; for (int idx = 0; idx < itemCount; idx++) { items[idx] = ReadItem(stream, errors); if (items[idx].MsgType == GXDebugMsgType.INVALID) { while (++idx < itemCount) { items[idx] = NewInvalidItem(); } break; } } FindEscape(stream, GXDebugStream.ESCAPE.EPILOG, errors); return(items); }
public static byte ToByte(this GXDebugGenId genId) { return((byte)genId); }