コード例 #1
0
        public ImparterTestService(IChannelFactory imparterChannels)
        {
            var commandHandler = new TestCommandHandler(imparterChannels);

            _incommingCommandsChannel = imparterChannels.GetSubscriberChannel("commands");
            _incommingCommandsChannel.Register <TestCommand>(commandHandler.Handle);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: pingustries/imparter
        private static void RunInputMode(IChannelFactory channelFactory)
        {
            var service = new ImparterTestService(channelFactory);

            service.Start();

            var commandChannel = channelFactory.GetImparterChannel("commands");

            var eventChannel = channelFactory.GetSubscriberChannel("events");

            eventChannel.Register <TestEvent>(new TestEventHandler().Handle);
            eventChannel.Subscribe();

            while (true)
            {
                var input = Console.ReadLine();
                if (input == "q")
                {
                    break;
                }
                commandChannel.Impart(new TestCommand(input)).GetAwaiter().GetResult();
            }

            eventChannel.Unsubscribe();
            service.Stop();
        }