public override IECGFormat Read(Stream input, int offset, ECGConfig cfg) { IECGFormat ret = null; LastError = 0; if ((input != null) && input.CanRead && input.CanSeek) { long pos = input.Position; int i = 0; ECGConverter converter = ECGConverter.Instance; for (; i < converter.getNrSupportedFormats(); i++) { if (converter.hasUnknownReaderSupport(i)) { try { ret = converter.getFormat(i); if ((ret != null) && ret.CheckFormat(input, offset + converter.getExtraOffset(i))) { ret.Read(input, offset + converter.getExtraOffset(i)); if (ret.Works()) { break; } } input.Position = pos; } catch {} if (ret != null) { ret.Dispose(); ret = null; } } } if (i == converter.getNrSupportedFormats()) { LastError = 2; } } else { LastError = 1; } return(ret); }
public override IECGFormat Read(byte[] buffer, int offset, ECGConfig cfg) { IECGFormat ret = null; LastError = 0; if (buffer != null) { int i = 0; ECGConverter converter = ECGConverter.Instance; for (; i < converter.getNrSupportedFormats(); i++) { if (converter.hasUnknownReaderSupport(i)) { try { ret = converter.getFormat(i); if ((ret != null) && ret.CheckFormat(buffer, offset + converter.getExtraOffset(i))) { ret.Read(buffer, offset + converter.getExtraOffset(i)); if (ret.Works()) { break; } } } catch {} if (ret != null) { ret.Dispose(); ret = null; } } } if (i == converter.getNrSupportedFormats()) { LastError = 2; } } else { LastError = 1; } return(ret); }