protected override string DetermineNextTypeName(Configuration configuration, BinaryContext context) { CreateTypeReaderFactory(configuration,context); long markerSize = GetMarkerSize(configuration, context); if (!context.CanReadBytes(markerSize)) { throw new InvalidOperationException("Unable to read next type marker from context"); } var markerBytes = context.PeekBytes(markerSize); var nextType = FindTypeForMarker(configuration, markerBytes); _typesCounter++; return nextType; }
public List<byte[]> Split(long sizeOffset, long sizeLength, BinaryContext context) { var result = new List<byte[]>(); while (!context.EndOfContextReached()) { var sizeValue = context.PeekBytes(sizeOffset, sizeLength); var size = ConvertSize(sizeValue); if (context.CanReadBytes(size)) { result.Add(context.ReadBytes(size)); } else throw new EndOfStreamException("Cannot read next block of size " + size); } return result; }
/// <summary> /// Splits the given context to several data arrays using the global RecordMarker metadata. /// </summary> /// <param name="configuration">the configuration to use</param> /// <param name="context">the binary context to work with</param> /// <returns>the result of splitting.</returns> public List<byte[]> Split(Configuration configuration, BinaryContext context) { var result = new List<byte[]>(); byte[] marker = RetrieveMarker(configuration, context); var positions=context.FindMarkers(marker); for (int i = 0; i < positions.Count; i++) { var index = positions[i]; var prevIndex = (i-1<0)?0:positions[i - 1]; var recordSize = index - prevIndex; if(context.CanReadBytes(recordSize+marker.Length)) { } } return result; }
public List<byte[]> Split(long sizeValue, BinaryContext context) { var result = new List<byte[]>(); while (!context.EndOfContextReached()) { if (context.CanReadBytes(sizeValue)) { result.Add(context.ReadBytes(sizeValue)); } else throw new EndOfStreamException("Cannot read next block of size " + sizeValue); } return result; }