public async IAsyncEnumerable <Event> ReadAllEventsFromStreamAsync(string stream) { var credentials = await _connectionProvider.GetCredentials(); long position = 0; var slice = default(StreamEventsSlice); do { slice = await _conn.ReadStreamEventsForwardAsync(stream, position, 100, false, credentials); switch (slice.Status) { case SliceReadStatus.StreamDeleted: throw new StreamDeletedException(stream); case SliceReadStatus.StreamNotFound: throw new StreamNotFoundException(stream); default: break; } foreach (var resolvedEvent in slice.Events) { if (resolvedEvent.OriginalStreamId[0] == '$') { continue; } var eventNumber = resolvedEvent.Event.EventNumber; position = eventNumber; var @event = _eventSerializer.DeseralizeEvent(resolvedEvent); yield return(@event); } if (!slice.IsEndOfStream) { position += 1; } }while (!slice.IsEndOfStream); yield break; }
protected override async Task ResetAsync() { var streamId = _streamId == null ? $"$ce-{_aggregateType.ToUpper()}" : _streamId.Id; using (var connection = _connectionProvider.GetConnection()) { await connection.ConnectAsync(); await connection.DeletePersistentSubscriptionAsync(streamId, _subscriptionName, await _connectionProvider.GetCredentials()); } }