internal EventStream ReadStream(string streamName)
        {
            lock (store)
            {
                List <EventValue> values              = new List <EventValue>();
                List <EventValue> storeCopy           = new List <EventValue>(store);
                EventValue        latestSnapshotValue = null;

                foreach (EventValue value in storeCopy)
                {
                    if (value.StreamName.Equals(streamName))
                    {
                        if (value.HasSnapshot())
                        {
                            values.Clear();
                            latestSnapshotValue = value;
                        }
                        else
                        {
                            values.Add(value);
                        }
                    }
                }

                int snapshotVersion = latestSnapshotValue == null ? 0 : latestSnapshotValue.StreamVersion;
                int streamVersion   = values.Count == 0 ? snapshotVersion : values[values.Count - 1].StreamVersion;

                return(new EventStream(streamName, streamVersion, values, latestSnapshotValue == null ? "" : latestSnapshotValue.Snapshot));
            }
        }
        public override bool Equals(object other)
        {
            if (other == null || other.GetType() != typeof(EventValue))
            {
                return(false);
            }

            EventValue otherEventValue = (EventValue)other;

            return(this.StreamName.Equals(otherEventValue.StreamName) &&
                   this.StreamVersion == otherEventValue.StreamVersion &&
                   this.Type.Equals(otherEventValue.Type) &&
                   this.Body.Equals(otherEventValue.Body) &&
                   this.Snapshot.Equals(otherEventValue.Snapshot));
        }
 internal StoredEvent(long id, EventValue eventValue)
 {
     this.Id         = id;
     this.EventValue = eventValue;
 }
 public override int GetHashCode()
 {
     return(EventValue.GetHashCode() + (int)Id);
 }