本文整理汇总了C#中Tracker.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# Tracker.Reset方法的具体用法?C# Tracker.Reset怎么用?C# Tracker.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tracker
的用法示例。
在下文中一共展示了Tracker.Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: basic_order_for_eight_handlers_interleaved
public void basic_order_for_eight_handlers_interleaved()
{
var tracker = new Tracker();
var unity = new UnityContainer()
.RegisterInstance(tracker);
var dispatcher = Dispatcher.Create(d => d
.SetUnityContainer(unity)
.RegisterHandler<Message1>((m, s) => s.GetInstance<Tracker>().Handlers.Add(typeof(Byte)))
.RegisterHandler<Message2>((m, s) => s.GetInstance<Tracker>().Handlers.Add(typeof(Byte)))
.RegisterHandler<Message1>((m, s) => s.GetInstance<Tracker>().Handlers.Add(typeof(Int16)))
.RegisterHandler<Message2>((m, s) => s.GetInstance<Tracker>().Handlers.Add(typeof(Int16)))
.RegisterHandler<Message2>((m, s) => s.GetInstance<Tracker>().Handlers.Add(typeof(Int32)))
.RegisterHandler<Message2>((m, s) => s.GetInstance<Tracker>().Handlers.Add(typeof(Int64)))
.RegisterHandler<Message1>((m, s) => s.GetInstance<Tracker>().Handlers.Add(typeof(Int32)))
.RegisterHandler<Message1>((m, s) => s.GetInstance<Tracker>().Handlers.Add(typeof(Int64)))
);
dispatcher.Dispatch(new Message1());
Assert.That(tracker.Handlers.Count, Is.EqualTo(4));
Assert.That(tracker.Handlers[0], Is.EqualTo(typeof(Byte)));
Assert.That(tracker.Handlers[1], Is.EqualTo(typeof(Int16)));
Assert.That(tracker.Handlers[2], Is.EqualTo(typeof(Int32)));
Assert.That(tracker.Handlers[3], Is.EqualTo(typeof(Int64)));
tracker.Reset();
dispatcher.Dispatch(new Message2());
Assert.That(tracker.Handlers.Count, Is.EqualTo(4));
Assert.That(tracker.Handlers[0], Is.EqualTo(typeof(Byte)));
Assert.That(tracker.Handlers[1], Is.EqualTo(typeof(Int16)));
Assert.That(tracker.Handlers[2], Is.EqualTo(typeof(Int32)));
Assert.That(tracker.Handlers[3], Is.EqualTo(typeof(Int64)));
}
示例2: message_dispatching_with_locator
public void message_dispatching_with_locator()
{
var tracker = new Tracker();
var unity = new UnityContainer()
.RegisterInstance(tracker);
var dispatcher = Dispatcher.Create(d => d
.SetUnityContainer(unity)
.RegisterHandler<Message1>((m, s) => { s.GetInstance<Tracker>().Messages.Add(m.GetType()); })
.RegisterHandler<Message2>((m, s) => { s.GetInstance<Tracker>().Messages.Add(m.GetType()); })
);
dispatcher.Dispatch(new Message1());
Assert.That(tracker.Messages.Count, Is.EqualTo(1));
Assert.That(tracker.Messages[0], Is.EqualTo(typeof(Message1)));
tracker.Reset();
dispatcher.Dispatch(new Message2());
Assert.That(tracker.Messages.Count, Is.EqualTo(1));
Assert.That(tracker.Messages[0], Is.EqualTo(typeof(Message2)));
tracker.Reset();
dispatcher.Dispatch(new Message3());
Assert.That(tracker.Messages.Count, Is.EqualTo(0));
}