protected internal void InitializeEventHistory()
        {
            if (eventHistory.Count > 0)
            {
                throw new InvalidOperationException("Event history has already been initialized.");
            }

            eventHistory.AddRange(sourceEvents);

            if (sourceSnapshot != null)
            {
                pendingEvents.SetVersion(Math.Max(eventHistory.Version, sourceSnapshot.Version));
            }
            else
            {
                pendingEvents.SetVersion(eventHistory.Version);
            }

            if (eventHistory.AggregateId != Id)
            {
                throw new ArgumentException("Event history does not match specified aggregate id");
            }
        }
        protected internal void InitializeEventHistory(IEnumerable <IEvent> sourceEvents)
        {
            if (eventHistory.Count > 0)
            {
                throw new InvalidOperationException("Event history has already been initialized.");
            }

            eventHistory.AddRange(sourceEvents);

            var version = Math.Max(eventHistory.Version, sourceSnapshot?.Version ?? 0);

            pendingEvents.SetVersion(version);

            if (eventHistory.AggregateId != Id)
            {
                throw new ArgumentException("Event history does not match specified aggregate id");
            }
        }