private void EnterWriteState(MzMLWriteState expectedWs, MzMLWriteState newWs) { if (consumedWriteStates.Contains(newWs)) { throw new MzLiteIOException("Can't reentering write state: '{0}'.", newWs); } EnsureWriteState(expectedWs); currentWriteState = newWs; consumedWriteStates.Add(newWs); }
private void EnsureWriteState(MzMLWriteState expectedWs) { if (currentWriteState == MzMLWriteState.ERROR) { throw new MzLiteIOException("Current write state is ERROR."); } if (currentWriteState == MzMLWriteState.CLOSED) { throw new MzLiteIOException("Current write state is CLOSED."); } if (currentWriteState != expectedWs) { throw new MzLiteIOException("Invalid write state: expected '{0}' but current is '{1}'.", expectedWs, currentWriteState); } }
private void LeaveWriteState(MzMLWriteState expectedWs, MzMLWriteState newWs) { EnsureWriteState(expectedWs); currentWriteState = newWs; }