public static bool Publish <TEntity>(IEnumerable <IEntity> entities, EntityPersistentOperater operType, EntityPersistentEventType eventType)
        {
            var _event  = new EntitiesArgs(entities, operType, eventType);
            var subject = new EntityPersistentSubject(typeof(TEntity), eventType, _event);

            SynchronizedSubscribeManager.Instance.Publish(subject);

            return(!_event.Cancel);
        }
        public async Task <bool> PublishAsync <TEntity>(IServiceProvider serviceProvider, IEnumerable <IEntity> entities, PersistentOperator operType, PersistentEventType eventType)
        {
            if (!entities.Any())
            {
                return(true);
            }

            var _event  = new EntitiesArgs(entities, operType, eventType);
            var subject = new PersistentSubject(typeof(TEntity), eventType, _event);

            await subMgr.PublishAsync(subject);

            await AcceptForServiceProviderAsync(serviceProvider, subject);

            return(!_event.Cancel);
        }
        public async Task <bool> PublishAsync(IServiceProvider serviceProvider, IEnumerable <IEntity> entities, PersistentOperator operType, PersistentEventType eventType)
        {
            IEntity first;

            if ((first = entities.FirstOrDefault()) == null)
            {
                return(true);
            }

            var _event     = new EntitiesArgs(entities, operType, eventType);
            var entityType = first.EntityType;
            var subject    = new PersistentSubject(entityType, eventType, _event);

            await subMgr.PublishAsync(subject);

            await AcceptForServiceProviderAsync(serviceProvider, subject);

            return(!_event.Cancel);
        }