private void ApplyChange(IDomainEvent e, bool isNew) { var applyMethodInfo = GetType().GetMethod("Apply", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { e.GetType() }, null); if (applyMethodInfo == null) { throw new InvalidOperationException($"Aggregate '{GetType().Name}' can't apply '{e.GetType().Name}' event type."); } applyMethodInfo.Invoke(this, new object[] { e }); IncrementedVersion(); if (isNew) { e.SetVersion(Version); e.SetTimestamp(UtcNow); _domainEvents.Add(e); } }