终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Class_InnerMessageBus.cs 2.4 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using BPASmartClient.MessageCommunication.MsgControl;
  2. using System;
  3. namespace BPASmartClient.MessageCommunication
  4. {
  5. /// <summary>
  6. /// 该类实现客户端构件间消息的传递,底层使用整编的构件消息API
  7. /// 创建人:奉友福
  8. /// 创建时间:2022-04-18
  9. /// Class_InnerMessageBus.GetInstance().ListenMessage(this, MessageName.xxname, "xxnameHandler");
  10. /// Class_InnerMessageBus.GetInstance().PostMessage(this, MessageName.xxname, "12321");
  11. /// public void xxnameHandler(object sender, InnerMessageEventArgs e) { }
  12. /// </summary>
  13. public class Class_InnerMessageBus
  14. {
  15. public static Class_InnerMessageBus _MessageBus = null;
  16. static InnerMessageBus Bus = null;
  17. public static Class_InnerMessageBus GetInstance()
  18. {
  19. if (_MessageBus == null)
  20. {
  21. _MessageBus = new Class_InnerMessageBus();
  22. Bus = new InnerMessageBus();
  23. }
  24. return _MessageBus;
  25. }
  26. /// <summary>
  27. /// 监听消息方法
  28. /// </summary>
  29. /// <param name="sender">订阅消息构件</param>
  30. /// <param name="str_MessageString">消息名称</param>
  31. /// <param name="str_MessageName">接收消息后回调处理函数 注意:该函数必须为Public</param>
  32. public void ListenMessage(object sender,string str_MessageString,string str_MessageName)
  33. {
  34. Bus.ListenMessage(sender,str_MessageString,str_MessageName);
  35. }
  36. /// <summary>
  37. /// 消息发送函数
  38. /// </summary>
  39. /// <param name="sender">发送消息构件</param>
  40. /// <param name="str_Msg">消息名称</param>
  41. /// <param name="obj_Data">消息体</param>
  42. public void PostMessage(object sender,string str_Msg,object obj_Data)
  43. {
  44. Bus.PostMessage(sender,str_Msg,obj_Data);
  45. }
  46. /// <summary>
  47. /// 移除消息方法
  48. /// </summary>
  49. /// <param name="str_MessageString">消息名称</param>
  50. /// <param name="str_处理方法名称">接收消息后回调处理函数</param>
  51. public void RemoveMessage(string str_MessageString,string str_MessageName)
  52. {
  53. Bus.ListenMessage_trunOff(str_MessageString,str_MessageName);
  54. }
  55. public int GetdRountCount()
  56. {
  57. return Bus.__Debug_RoutTable.Count;
  58. }
  59. }
  60. }