当前位置: 首页>>代码示例>>C#>>正文


C# Messenger.NotifyColleagues方法代码示例

本文整理汇总了C#中Messenger.NotifyColleagues方法的典型用法代码示例。如果您正苦于以下问题:C# Messenger.NotifyColleagues方法的具体用法?C# Messenger.NotifyColleagues怎么用?C# Messenger.NotifyColleagues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Messenger的用法示例。


在下文中一共展示了Messenger.NotifyColleagues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MessageWithParameterIsReceived

        public void MessageWithParameterIsReceived()
        {
            Messenger target = new Messenger();

            bool received = false;

            string paramValue = "whatever";

            target.Register("MESSAGE", (Action<string>)(param => received = (param == paramValue)));

            target.NotifyColleagues("MESSAGE", paramValue);

            Assert.IsTrue(received);
        }
开发者ID:ssickles,项目名称:archive,代码行数:14,代码来源:MessengerTests.cs

示例2: MessageWithoutParameterIsReceived

        public void MessageWithoutParameterIsReceived()
        {
            Messenger target = new Messenger();

            bool received1 = false;
            bool received2 = false;

            target.Register("MESSAGE", (Action)(() => received1 = true));
            target.Register("MESSAGE", (Action)(() => received2 = true));

            target.NotifyColleagues("MESSAGE");

            Assert.IsTrue(received1);
            Assert.IsTrue(received2);
        }
开发者ID:ssickles,项目名称:archive,代码行数:15,代码来源:MessengerTests.cs

示例3: ColleaguesAreNotifiedInRegistrationOrder

        public void ColleaguesAreNotifiedInRegistrationOrder()
        {
            Messenger target = new Messenger();

            int notificationCounter = 0;
            int notified1 = 0;
            int notified2 = 0;

            target.Register("MESSAGE", (Action)(() => notified1 = ++notificationCounter));
            target.Register("MESSAGE", (Action)(() => notified2 = ++notificationCounter));

            target.NotifyColleagues("MESSAGE");

            Assert.AreEqual(1, notified1 );
            Assert.AreEqual(2, notified2);
        }
开发者ID:ssickles,项目名称:archive,代码行数:16,代码来源:MessengerTests.cs

示例4: ExceptionIsThrownIfUnexpectedParameterIsPassed

        public void ExceptionIsThrownIfUnexpectedParameterIsPassed()
        {
            Messenger target = new Messenger();
            
            target.Register("MESSAGE", () => Debug.WriteLine("No parameter expected"));

            target.NotifyColleagues("MESSAGE", "Unexpected parameter");
        }
开发者ID:ssickles,项目名称:archive,代码行数:8,代码来源:MessengerTests.cs

示例5: ExceptionIsThrownIfParameterIsMissing

        public void ExceptionIsThrownIfParameterIsMissing()
        {
            Messenger target = new Messenger();

            target.Register("MESSAGE", (Action<string>)(param => Debug.Write(param)));

            target.NotifyColleagues("MESSAGE");
        }
开发者ID:ssickles,项目名称:archive,代码行数:8,代码来源:MessengerTests.cs

示例6: StaticCallbackMethodIsInvoked

        public void StaticCallbackMethodIsInvoked()
        {
            Messenger target = new Messenger();

            _wasStaticCallbackMethodInvoked = false;

            target.Register("MESSAGE", (Action)StaticCallbackMethod);

            target.NotifyColleagues("MESSAGE");

            Assert.IsTrue(_wasStaticCallbackMethodInvoked);
        }
开发者ID:ssickles,项目名称:archive,代码行数:12,代码来源:MessengerTests.cs


注:本文中的Messenger.NotifyColleagues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。