public async Task <IList <ResolvedEvent> > ConvertAsync(EventStoreStreamsAttribute config, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(config?.ConnectionStringSetting)) { var esException = new EventStoreStreamsBindingException("ConnectionString cant be empty"); _logger.LogError(esException, esException.Message); throw esException; } using (var client = new EventStoreClient(config.ConnectionStringSetting, _logger)) { try { await client.Connect(); IList <ResolvedEvent> result = null; if (config.StreamReadDirection == StreamReadDirection.Forward) { result = await client.ReadFromStreamForward(config.StreamName, config.StreamOffset, config.ReadSize, config.ResolveLinkTos); } else { result = await client.ReadFromStreamBackward(config.StreamName, config.StreamOffset, config.ReadSize, config.ResolveLinkTos); } return(result); } catch (Exception esException) { _logger.LogError(esException, esException.Message); throw; } } }