unsafe bool IEnumerator.MoveNext() { SL3Reader src = source; if (src.Read(new(pCurrent, Frame.Size)) != Frame.Size) { return(false); // Unable to read. It could be due to EOF or IO error. } return(src.Seek(pCurrent->TotalLength - Frame.Size, SeekOrigin.Current) < fileLength); // Avoid returning non-complete frame. }
public unsafe Enumerator(SL3Reader source) { bool lockTaken = false; Monitor.Enter(source, ref lockTaken); if (!lockTaken) { throw new IOException("Unable to lock stream for single access use."); } aCurrent = GC.AllocateArray <Frame>(1, true); pCurrent = (Frame *)Unsafe.AsPointer(ref aCurrent[0]); this.source = source; fileLength = source.Length; ((IEnumerator)this).Reset(); }