public void SegmentEnumeratorBitmap() { using (var fileStream = new FileStream("Evic11.dec", FileMode.Open, FileAccess.Read)) { var imageEnumerator = new SegmentEnumerator<Bitmap>( fileStream, Versions.Evic11.Images, new BitmapReader()); ISegmentData<Bitmap> segmentData = null; while (imageEnumerator.MoveNext()) { segmentData = imageEnumerator.Current; Assert.IsNotNull(segmentData); } Assert.IsNotNull(segmentData); Assert.IsNull(imageEnumerator.Current); Assert.IsTrue(fileStream.Position == Versions.Evic11.Images.Offset + Versions.Evic11.Images.Size); } }
public void SegmentEnumeratorString() { using (var fileStream = new FileStream("Evic11.dec", FileMode.Open, FileAccess.Read)) { var imageEnumerator = new SegmentEnumerator<string>( fileStream, Versions.Evic11.Strings, new StringReader()); ISegmentData<string> segmentData = null; while (imageEnumerator.MoveNext()) { segmentData = imageEnumerator.Current; Assert.IsNotNull(segmentData); Assert.IsTrue(string.IsNullOrWhiteSpace(segmentData.Data) == false); Console.WriteLine(segmentData.Data); } Assert.IsNotNull(segmentData); Assert.IsNull(imageEnumerator.Current); Assert.IsTrue(fileStream.Position == Versions.Evic11.Strings.Offset + Versions.Evic11.Strings.Size); } }
public static int Seek(ReadCursor begin, ReadCursor end, out ReadCursor result, byte byte0, byte byte1, byte byte2) { var enumerator = new SegmentEnumerator(begin, end); while (enumerator.MoveNext()) { var segmentPart = enumerator.Current; var segment = segmentPart.Segment; var span = segment.Buffer.Span.Slice(segmentPart.Start, segmentPart.Length); int index = span.IndexOfAny(byte0, byte1, byte2); if (index != -1) { result = new ReadCursor(segment, segmentPart.Start + index); return(span[index]); } } result = end; return(-1); }
/// <summary> /// /// </summary> public MemoryEnumerator(ReadCursor start, ReadCursor end) { _segmentEnumerator = new SegmentEnumerator(start, end); _current = Memory <byte> .Empty; }
/// <summary> /// /// </summary> public BufferEnumerator(ReadCursor start, ReadCursor end) { _segmentEnumerator = new SegmentEnumerator(start, end); _current = default; }
/// <summary> /// /// </summary> public MemoryEnumerator(ReadCursor start, ReadCursor end) { _segmentEnumerator = new SegmentEnumerator(start, end); _current = default(Memory <byte>); }