/// <summary> /// 发送消息 /// </summary> /// <param name="messageType">消息的分类</param> /// <param name="kv">键值对(对象)</param> public static void SendMessage(string messageType, KeyValueUpdate kv) { DelMessageDelivery del = null; if (!_dicMessages.TryGetValue(messageType, out del)) { return; } if (del != null) { del(kv); // 调用委托 } }
/* 不使用MVC框架时,用来传递UI之间的消息 */ /// <summary> /// 发送消息方法 /// </summary> /// <param name="msgType">消息的类型</param> /// <param name="msgName">消息的名字</param> /// <param name="msgContent">消息的内容</param> protected void MySendMessage(string msgType, string msgName, object msgContent) { KeyValueUpdate kv = new KeyValueUpdate(msgName, msgContent); MessageCenter.SendMessage(msgType, kv); }