/// <summary>
        /// Scopes the specified scope.
        /// </summary>
        /// <returns></returns>
        public IDomainEventScope Scope()
        {
            var eventScope = new DomainEventScope(this);

            _scopes.Add(eventScope);

            return(eventScope);
        }
        /// <summary>
        /// Un-scopes the specified scope.
        /// </summary>
        /// <param name="scope">The scope.</param>
        internal async Task UnscopeAsync(DomainEventScope scope)
        {
            if (ReferenceEquals(scope, _scopes[0]))
            {
                foreach (var eventScope in _scopes)
                {
                    var events = eventScope.Events;
                    if (events.Any())
                    {
                        await _mediator.Publish(new DomainEventNotification(eventScope.Events));
                    }
                }

                _scopes.Clear();
            }
        }