using BPASmartClient.MessageCommunication.MsgControl; using System; namespace BPASmartClient.MessageCommunication { /// /// 该类实现客户端构件间消息的传递,底层使用整编的构件消息API /// 创建人:奉友福 /// 创建时间:2022-04-18 /// Class_InnerMessageBus.GetInstance.ListenMessage(this, MessageName.xxname, "xxnameHandler"); /// Class_InnerMessageBus.GetInstance.PostMessage(this, MessageName.xxname, "12321"); /// public void xxnameHandler(object sender, InnerMessageEventArgs e) { } /// public class Class_InnerMessageBus { public static Class_InnerMessageBus _MessageBus = null; static InnerMessageBus Bus = null; public static Class_InnerMessageBus GetInstance { if (_MessageBus == null) { _MessageBus = new Class_InnerMessageBus(); Bus = new InnerMessageBus(); } return _MessageBus; } /// /// 监听消息方法 /// /// 订阅消息构件 /// 消息名称 /// 接收消息后回调处理函数 注意:该函数必须为Public public void ListenMessage(object sender,string str_MessageString,string str_MessageName) { Bus.ListenMessage(sender,str_MessageString,str_MessageName); } /// /// 消息发送函数 /// /// 发送消息构件 /// 消息名称 /// 消息体 public void PostMessage(object sender,string str_Msg,object obj_Data) { Bus.PostMessage(sender,str_Msg,obj_Data); } /// /// 移除消息方法 /// /// 消息名称 /// 接收消息后回调处理函数 public void RemoveMessage(string str_MessageString,string str_MessageName) { Bus.ListenMessage_trunOff(str_MessageString,str_MessageName); } public int GetdRountCount() { return Bus.__Debug_RoutTable.Count; } } }