CAB实现 MBS
<p>MBS 重新设计和实现了 CAB (Composite UI Application Block) 同时集成了消息总线、IoC 以及 UI 插件。</p> <p>消息总线的例子:</p> <p>1. string of message content<br /> var MB = new MessageBus();//create message bus<br /> var unsubscriber = MB.Subscribe((s,e)=>Console.WriteLine(e));//subscribe the string of message content<br /> MB.Publish("hello Message Bus!");//public the string of message content<br /> unsubscriber.Dispose();//un subscribe<br /> <br /> 2. int type of message<br /> var MB = new MessageBus();//create message bus<br /> var unsubscriber = MB.Subscribe((s,e)=>Console.WriteLine(e));//subscribe int message type<br /> MB.Publish(521);//publish<br /> unsubscriber.Dispose();//unsubscribe<br /> <br /> 3. User defined Message<br /> public class Person<br /> {<br /> public string Name { get;set;}<br /> public int Age { get;set;}<br /> public bool Sex { get;set;}<br /> } <br /> <br /> var MB = new MessageBus();//create message bus<br /> var unsubscriber = MB.Subscribe((s,e)=>Console.WriteLine(e.Name));// subscribe Persion Message (the output is Persion.Name)<br /> MB.Publish(new Person { Name = "ZhangSan"});//publish Person Message<br /> unsubscriber.Dispose();//unSubscribe<br /> <br /> <br /> </p> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1327494918468" target="_blank">http://www.open-open.com/lib/view/home/1327494918468</a></p>
本文由用户 fmms 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!