本文整理汇总了C#中EventAggregator.TryGetEventHandler方法的典型用法代码示例。如果您正苦于以下问题:C# EventAggregator.TryGetEventHandler方法的具体用法?C# EventAggregator.TryGetEventHandler怎么用?C# EventAggregator.TryGetEventHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventAggregator
的用法示例。
在下文中一共展示了EventAggregator.TryGetEventHandler方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetEventHandler_should_return_false_when_no_subscribers_exist
public void TryGetEventHandler_should_return_false_when_no_subscribers_exist()
{
var subject = new EventAggregator();
Action<int> handler;
subject.TryGetEventHandler(out handler).Should().BeFalse();
}
示例2: TryGetEventHandler_should_return_true_when_one_subscriber_exists
public void TryGetEventHandler_should_return_true_when_one_subscriber_exists()
{
var subject = new EventAggregator();
subject.Subscribe<int>(x => { });
Action<int> handler;
subject.TryGetEventHandler(out handler).Should().BeTrue();
}
示例3: Handler_should_invoke_a_single_subscriber
public void Handler_should_invoke_a_single_subscriber()
{
var subject = new EventAggregator();
bool called = false;
subject.Subscribe<int>(x => called = true);
Action<int> handler;
subject.TryGetEventHandler(out handler);
handler(42);
called.Should().BeTrue();
}
示例4: Handler_should_invoke_multiple_subscribers
public void Handler_should_invoke_multiple_subscribers()
{
var subject = new EventAggregator();
bool called1 = false;
bool called2 = false;
bool called3 = false;
subject.Subscribe<int>(x => called1 = true);
subject.Subscribe<int>(x => called2 = true);
subject.Subscribe<int>(x => called3 = true);
Action<int> handler;
subject.TryGetEventHandler(out handler);
handler(42);
called1.Should().BeTrue();
called2.Should().BeTrue();
called3.Should().BeTrue();
}