本文整理汇总了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);
}
示例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);
}
示例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);
}
示例4: ExceptionIsThrownIfUnexpectedParameterIsPassed
public void ExceptionIsThrownIfUnexpectedParameterIsPassed()
{
Messenger target = new Messenger();
target.Register("MESSAGE", () => Debug.WriteLine("No parameter expected"));
target.NotifyColleagues("MESSAGE", "Unexpected parameter");
}
示例5: ExceptionIsThrownIfParameterIsMissing
public void ExceptionIsThrownIfParameterIsMissing()
{
Messenger target = new Messenger();
target.Register("MESSAGE", (Action<string>)(param => Debug.Write(param)));
target.NotifyColleagues("MESSAGE");
}
示例6: StaticCallbackMethodIsInvoked
public void StaticCallbackMethodIsInvoked()
{
Messenger target = new Messenger();
_wasStaticCallbackMethodInvoked = false;
target.Register("MESSAGE", (Action)StaticCallbackMethod);
target.NotifyColleagues("MESSAGE");
Assert.IsTrue(_wasStaticCallbackMethodInvoked);
}