/// <summary> /// 发送消息 /// </summary> /// <param name="msgType">信道ID</param> /// <param name="data">消息数据</param> /// <param name="sender">发送者对象</param> public static void Send(string msgType, object data, object sender = null) { MsgEventArgs args = new MsgEventArgs(msgType); args.Data = data; MsgEventFactory.EventsContainer.Run(sender, args); }
public void Run(Object sender, MsgEventArgs args) { if (appEventHandler != null) { appEventHandler(sender, args); } #region 去除那些只绑定一次处理事件的对象 for (int i = 0; i < Receivers.Count; i++) { try { MsgReceiver item = Receivers[i]; if (item == null) { continue; } if (item.IsOnce) { AppEventHandler -= item.appEventHandler; Receivers.Remove(item); } } catch { Console.WriteLine("去除接受者对象列表中内容错误!"); } } #endregion }
public void Run(Object sender, MsgEventArgs args) { string msgType = args.EventType; //未存在注册的消息事件,则直接返回 if (eventsList.ContainsKey(msgType) == false) { return; } MsgEventProvider msgEventProvider = eventsList[msgType]; msgEventProvider.Run(sender, args); }
/// <summary> /// 发送消息 /// </summary> /// <param name="msgType">信道ID</param> /// <param name="data">消息数据</param> /// <param name="sender">发送者对象</param> public static void Send(string msgType,object data,object sender=null) { MsgEventArgs args = new MsgEventArgs(msgType); args.Data = data; MsgEventFactory.EventsContainer.Run(sender, args); }
public void Run(Object sender,MsgEventArgs args) { string msgType = args.EventType; //未存在注册的消息事件,则直接返回 if(eventsList.ContainsKey(msgType)==false)return; MsgEventProvider msgEventProvider = eventsList[msgType]; msgEventProvider.Run(sender, args); }
/// <summary> /// 发送消息 /// </summary> /// <param name="args">消息体对象</param> /// <param name="sender">发送者对象</param> public static void Send(MsgEventArgs args,object sender =null) { MsgEventFactory.EventsContainer.Run(sender, args); }
public void Run(Object sender,MsgEventArgs args) { if (appEventHandler!=null) { appEventHandler(sender, args); } #region 去除那些只绑定一次处理事件的对象 for (int i=0;i<Receivers.Count;i++) { try { MsgReceiver item = Receivers[i]; if(item==null)continue; if (item.IsOnce) { AppEventHandler -= item.appEventHandler; Receivers.Remove(item); } } catch { Console.WriteLine("去除接受者对象列表中内容错误!"); } } #endregion }
/// <summary> /// 发送消息 /// </summary> /// <param name="args">消息体对象</param> /// <param name="sender">发送者对象</param> public static void Send(MsgEventArgs args, object sender = null) { MsgEventFactory.EventsContainer.Run(sender, args); }