public GTrack Read(Stream MapStream) { var data = ReadBytes(MapStream, _recordLength); var number = data[0]; var childrenCount = data[1]; var childrenStartAddress = SubInt(data, 2, 3); if (childrenStartAddress == 0xffffff) { return(null); } var track = new GTrack(number); if (childrenCount > 0) { if (childrenStartAddress == 0) { throw new IndexOutOfRangeException(); } var previousPosition = MapStream.Position; MapStream.Seek(childrenStartAddress, SeekOrigin.Begin); for (var i = 0; i < childrenCount; i++) { var obj = _objectReader.Read(MapStream); track.Objects.Add(obj); } MapStream.Seek(previousPosition, SeekOrigin.Begin); } return(track); }
public async Task <Stream?> Read(string objectName, CancellationToken cancellationToken) { Stream?result; try { result = await _inner.Read(objectName, cancellationToken); } catch (OperationCanceledException) { throw; } catch { _writer.Add(_prefix + "read_errors", 1); throw; } _writer.Add(_prefix + "reads", 1); if (result is object) { _writer.Add(_prefix + "reads_length", result.Length); } return(result); }
public T Execute(IRdbmsProviderCommandExecutionContext executionContext) { ArgumentUtility.CheckNotNull("executionContext", executionContext); using (var command = _dbCommandBuilder.Create(executionContext)) { using (var reader = executionContext.ExecuteReader(command, CommandBehavior.SingleRow)) { return(_objectReader.Read(reader)); } } }
public async Task <Stream?> Read(string objectName, CancellationToken cancellationToken) { try { return(await _inner.Read(objectName, cancellationToken)); } catch (GridFSChunkException exception) when( exception.Message.StartsWith("GridFS chunk ", StringComparison.Ordinal) && exception.Message.EndsWith(" is missing.", StringComparison.Ordinal)) { return(null); } }
public async Task <Stream?> Read(string objectName, CancellationToken cancellationToken) { using var stream = await _inner.Read(objectName, cancellationToken); if (stream is object) { var length = checked ((int)stream.Length); var bufferedStream = new RecyclableMemoryStream(_streamManager, nameof(BufferingObjectReader), length); await stream.CopyToAsync(bufferedStream, cancellationToken); return(bufferedStream); } return(stream); }
public async Task <Stream?> Read(string objectName, CancellationToken cancellationToken) { if (objectName is null) { throw new ArgumentNullException(nameof(objectName)); } try { return(await _inner.Read(objectName, cancellationToken)); } catch (OperationCanceledException) { throw; } #pragma warning disable CA1031 // Do not catch general exception types -- failing to read file just skips it catch #pragma warning restore CA1031 // Do not catch general exception types { return(null); } }
public async Task <Stream?> Read(string objectName, CancellationToken cancellationToken) { var retries = _retries; while (true) { try { return(await _inner.Read(objectName, cancellationToken)); } catch (OperationCanceledException) { throw; } #pragma warning disable CA1031 // Do not catch general exception types -- dumb retry mechanism catch when(retries-- > 0) #pragma warning restore CA1031 // Do not catch general exception types { } await Task.Delay(1511, cancellationToken); } }
void ICustomSerializable.Read(IObjectReader reader) { Guard.NotNull(reader, "reader"); Location = reader.Read<SpeedCaptureLocation>(); var speeds = new KeyValuePair<string, int>[reader.Read<int>()]; for(int i = 0; i < speeds.Length; ++i) { speeds[i] = new KeyValuePair<string, int>(reader.Read<string>(), reader.Read<int>()); } Speeds = Array.AsReadOnly(speeds); }
public Task <Stream?> Read(string objectName, CancellationToken cancellationToken) => _reader.Read(objectName, cancellationToken);