internal static void Initialize() { EventAttribute.Initialize(); //订阅事件 SubscribeEvents(); EventRestorer.RestoreAsync(); InitTimer(); }
/// <summary> /// /// </summary> /// <param name="tip"></param> private static void CanceleReverse(EventAttribute tip) { if (!tip.IsEnabled) { return; } var reverseName = EventUtil.GetReverse(tip.Name); EventPortal.Cancel(reverseName); }
/// <summary> /// 订阅回逆 /// </summary> /// <param name="tip"></param> private static void SubscribeReverse(EventAttribute tip) { if (!tip.IsEnabled) { return; } var reverseName = EventUtil.GetReverse(tip.Name); EventPortal.Subscribe(reverseName, ReverseEventHandler.Instance); }
/// <summary> /// 订阅触发 /// </summary> /// <param name="tip"></param> private static void SubscribeRaise(EventAttribute tip) { if (!tip.IsEnabled) { return; } var raiseName = EventUtil.GetRaise(tip.Name); //作为事件的提供方,我们订阅了触发事件,这样当外界发布了“触发事件”后,这里就可以收到消息并且执行事件 EventPortal.Subscribe(raiseName, RaiseEventHandler.Instance); }
/// <summary> /// 禁用事件 /// </summary> /// <param name="eventNames"></param> public static void DisabledEvent(params string[] eventNames) { var tips = EventAttribute.Tips; foreach (var eventName in eventNames) { var tip = EventAttribute.GetTip(eventName, false); if (tip != null) { tip.IsEnabled = false; } } }
public static EventAttribute GetTip(string eventName, bool throwError) { EventAttribute tip = null; if (_nameTips.TryGetValue(eventName, out tip)) { return(tip); } if (throwError) { throw new DomainEventException(string.Format(Strings.NoEvent, eventName)); } return(null); }
public static DomainEvent GetLocalEvent(string eventName, DTObject args, bool throwError) { //因为领域事件的处理被事件锁锁了,所以这里不存在并发问题,不需要锁cache var tip = EventAttribute.GetTip(eventName, throwError); if (tip == null) { return(null); } if (!tip.IsEnabled) { return(null); //如果宿主过滤该事件,那么事件不是本地的 } var @event = (DomainEvent)tip.EventType.GetConstructor(Array.Empty <Type>()).CreateInstance(null); if (!args.IsEmpty()) { @event.SetArgs(args); } return(@event); }