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


C# Tracker.Reset方法代码示例

本文整理汇总了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)));

        }
开发者ID:paralect,项目名称:Paralect.ServiceBus,代码行数:34,代码来源:BasicOrderTest.cs

示例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));
        }
开发者ID:paralect,项目名称:Paralect.ServiceBus,代码行数:25,代码来源:DispatcherTests.cs


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