internal StreamEventsSlice(SliceReadStatus status, string stream, int fromEventNumber, ReadDirection readDirection, ClientMessage.ResolvedIndexedEvent[] events, int nextEventNumber, int lastEventNumber, bool isEndOfStream) { Ensure.NotNullOrEmpty(stream, "stream"); Status = status; Stream = stream; FromEventNumber = fromEventNumber; ReadDirection = readDirection; if (events == null || events.Length == 0) { Events = Empty.ResolvedEvents; } else { Events = new ResolvedEvent[events.Length]; for (int i = 0; i < Events.Length; ++i) { Events[i] = new ResolvedEvent(events[i]); } } NextEventNumber = nextEventNumber; LastEventNumber = lastEventNumber; IsEndOfStream = isEndOfStream; }
internal StreamEventsSlice(SliceReadStatus status, string stream, int fromEventNumber, ReadDirection readDirection, ClientMessage.ResolvedIndexedEvent[] events, int nextEventNumber, int lastEventNumber, bool isEndOfStream) { Ensure.NotNullOrEmpty(stream, "stream"); Status = status; Stream = stream; FromEventNumber = fromEventNumber; ReadDirection = readDirection; if (events == null || events.Length == 0) Events = Empty.ResolvedEvents; else { Events = new ResolvedEvent[events.Length]; for (int i = 0; i < Events.Length; ++i) { Events[i] = new ResolvedEvent(events[i]); } } NextEventNumber = nextEventNumber; LastEventNumber = lastEventNumber; IsEndOfStream = isEndOfStream; }
/// <summary> /// Check if stream exists /// </summary> /// <param name="connection">connection to ES</param> /// <param name="streamName">Name of the stream</param> /// <returns>True if stream exists</returns> public static bool StreamExits(IEventStoreConnection connection, string streamName) { var lastEventsStream = connection.ReadStreamEventsBackwardAsync(streamName.ToLower(), 0, 1, false).Result; SliceReadStatus status = lastEventsStream.Status; return(status == 0); }
private EventStoreStreamsBindingException HandleError(SliceReadStatus error) { switch (error) { case SliceReadStatus.StreamDeleted: return(new EventStoreStreamsBindingStreamDeletedException($"Unable to read from Stream: '{nameof(SliceReadStatus.StreamDeleted)}'")); case SliceReadStatus.StreamNotFound: return(new EventStoreStreamsBindingStreamNotFoundException($"Unable to read from Stream: '{nameof(SliceReadStatus.StreamNotFound)}'")); default: return(new EventStoreStreamsBindingException($"This is really an unexpected error!")); } }
internal EventStreamSlice(SliceReadStatus status, string stream, int start, int count, IEnumerable<ClientMessage.EventLinkPair> events, int nextEventNumber, int lastEventNumber, bool isEndOfStream) { Ensure.NotNullOrEmpty(stream, "stream"); Status = status; Stream = stream; Start = start; Count = count; Events = events == null ? EmptyEvents : events.Select(e => new RecordedEvent(e.Event)).ToArray(); NextEventNumber = nextEventNumber; LastEventNumber = lastEventNumber; IsEndOfStream = isEndOfStream; }
internal EventStreamSlice(SliceReadStatus status, string stream, int start, int count, IEnumerable <ClientMessage.EventLinkPair> events, int nextEventNumber, int lastEventNumber, bool isEndOfStream) { Ensure.NotNullOrEmpty(stream, "stream"); Status = status; Stream = stream; Start = start; Count = count; Events = events == null ? EmptyEvents : events.Select(e => new RecordedEvent(e.Event)).ToArray(); NextEventNumber = nextEventNumber; LastEventNumber = lastEventNumber; IsEndOfStream = isEndOfStream; }