Ejemplo n.º 1
0
        /// <summary>
        /// 执行事件
        /// </summary>
        protected virtual void ExecutEvent(IList <IUnitofwork> unitofworks, EventHandleSequenceType sequenceType, TEntityType info)
        {
            if (EventHandles == null || info == null)
            {
                return;
            }
            DomainService.SetItemLoaders(info);
            var handles = EventHandles.GetHandles(sequenceType, info.EventName);

            if (handles == null)
            {
                return;
            }
            foreach (var eventHandle in handles)
            {
                var args = new EventHandleArgs <TEntityType>
                {
                    Entity      = info,
                    Unitofworks = unitofworks,
                    Sender      = eventHandle
                };
                if (eventHandle.IsAsynchronization)
                {
                    eventHandle.Handle.BeginInvoke(args, null, null);
                }
                else
                {
                    eventHandle.Handle(args);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 执行事件
 /// </summary>
 protected virtual void ExecutEvent(IList <IUnitofwork> unitofworks, EventHandleSequenceType sequenceType, IList <TEntityType> infos)
 {
     if (EventHandles == null ||  infos == null)
     {
         return;
     }
     foreach (var info in infos)
     {
         ExecutEvent(unitofworks, sequenceType, info);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到
 /// </summary>
 /// <param name="sequenceType"></param>
 /// <param name="eventName"></param>
 /// <returns></returns>
 public virtual IList <EventHandle <TEntityType> > GetHandles(EventHandleSequenceType sequenceType, string eventName)
 {
     if (string.IsNullOrEmpty(eventName) || EventHandles == null)
     {
         return(null);
     }
     if (!EventHandles.ContainsKey(sequenceType) || !EventHandles[sequenceType].ContainsKey(eventName))
     {
         return(null);
     }
     return(EventHandles[sequenceType][eventName]);
 }