private void ProcessTags(ByteBuffer tagBuffer) { while (true) { if (tagBuffer.Data.Length < 0x08) { // Not enough data... return; } string tagMagic = Encoding.ASCII.GetString(tagBuffer.Data, 0x00, 0x04); IJHITagProcessor processor = tagDispatch[tagMagic]; int tagSize = JHI.SwapBytes(BitConverter.ToInt32(tagBuffer.Data, 0x04)); if (tagBuffer.Data.Length < 0x08 + tagSize) { // Not enough data... return; } // Tag is done! JHITag tag = new JHITag(); tag.Magic = tagMagic; tag.Data = tagBuffer.Data.AsSpan(0x08, tagSize).ToArray(); tagBuffer.DoneReading(0x08 + tagSize); processor.ProcessTag(tag); } }
public void RegisterTagProcessor(IJHITagProcessor tagProcessor) { tagDispatch.Add(tagProcessor.GetMagic(), tagProcessor); }