本文整理汇总了C#中Subscriber.Call方法的典型用法代码示例。如果您正苦于以下问题:C# Subscriber.Call方法的具体用法?C# Subscriber.Call怎么用?C# Subscriber.Call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscriber
的用法示例。
在下文中一共展示了Subscriber.Call方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Subscriber
public void EventでUnsubscribe()
{
var subscriber = new Subscriber();
int callNum1 = 0;
int callNum2 = 0;
int callNum3 = 0;
subscriber.Subscribe("topic1", () => { callNum1++; });
var e = subscriber.Subscribe("topic1", () => { callNum2++; });
subscriber.Subscribe("topic2", () => { callNum3++; });
subscriber.Call("topic1");
subscriber.Call("topic2");
subscriber.Call("topic1");
subscriber.Call("topic2");
subscriber.Unsubscribe(e);
subscriber.Call("topic1");
subscriber.Call("topic2");
subscriber.Call("topic1");
subscriber.Call("topic2");
Assert.AreEqual(callNum1, 4);
Assert.AreEqual(callNum2, 2);
Assert.AreEqual(callNum3, 4);
}
示例2: Mute
public void Mute()
{
var subscriber = new Subscriber();
int callNum1 = 0;
subscriber.Subscribe("topic1", () => { callNum1++; });
subscriber.Call("topic1");
Assert.AreEqual(callNum1, 1);
subscriber.Mute("topic1");
subscriber.Call("topic1");
Assert.AreEqual(callNum1, 1);
}
示例3: Call
public void Call()
{
var subscriber = new Subscriber();
int callNum1 = 0;
int callNum2 = 0;
int callNum3 = 0;
subscriber.Subscribe("topic1", () => { callNum1++; });
subscriber.Subscribe("topic1", () => { callNum2++; });
subscriber.Subscribe("topic2", () => { callNum3++; });
subscriber.Call("topic1");
subscriber.Call("topic2");
subscriber.Call("topic1");
subscriber.Call("topic2");
Assert.AreEqual(callNum1, 2);
Assert.AreEqual(callNum2, 2);
Assert.AreEqual(callNum3, 2);
}