Command를 관리하고, 실행하는 클래스 모든 Command들은 여기를 무조건 통하게 해야 한다.
예제 #1
0
        public void ExecuteAsync_NoHandlerDefined_ThrowsException()
        {
            var commandDispatcher = new CommandDispatcher(t => { throw new Exception(); });
              var expectedMessage = string.Format("Can not resolve handler for ICommandHandler<{0}>", typeof(ICommand).Name);

              Assert.That(async () => await commandDispatcher.DispatchAsync(_command), Throws.InstanceOf<ResolverException>().And.Message.EqualTo(expectedMessage));
        }
예제 #2
0
        public void Dispatch_QueryHandlerResolved_CallsHandleMethod()
        {
            var commandDispatcher = new CommandDispatcher(t => _handler);

              commandDispatcher.Dispatch(_command);

              _handler.CallsTo(m => m.Handle(_command)).MustHaveHappened(Repeated.Exactly.Once);
        }
예제 #3
0
        public static void parseArguments(String[] args, CommandDispatcher cd)
        {
            try
            {
                CommandLineDictionary dict = CommandLineDictionary.FromArguments(args, '-', '=');
                // Shorthand
                Func<string, bool> hasPar = (string key) => hasParameter(dict, key);

                if (hasPar("install"))
                    cd.addCommand(() => RegistryManipulator.install());

                else if (hasPar("uninstall"))
                    cd.addCommand(() => RegistryManipulator.uninstall());

                else if(hasFileParameter(dict)){
                    var filename = dict["file"];
                    if(hasPar("resizePercentage"))
                        cd.addCommand(() => ImageManipulators.setNewSize(filename, Byte.Parse(dict["resizePercentage"])));

                    if (hasPar("resizeSlider"))
                        cd.addCommand(() => {
                            var p = new PercentageSlider();
                            var perc = p.getSelection();
                            return ImageManipulators.setNewSize(filename, perc);
                        });

                    if (hasPar("sepiaPercentage"))
                        cd.addCommand(() => ImageManipulators.setSepiaTone(filename, Byte.Parse(dict["sepiaPercentage"])));

                    if(hasPar("grayScale"))
                        cd.addCommand(() => ImageManipulators.setColorspace(filename, "gray"));

                    if (hasPar("more-contrast"))
                        cd.addCommand(() => ImageManipulators.setContrast(filename, "-contrast"));

                    if (hasPar("less-contrast"))
                        cd.addCommand(() => ImageManipulators.setContrast(filename, "+contrast"));

                    if (hasPar("addBorder") && hasPar("borderColor"))
                        cd.addCommand(() => ImageManipulators.setBorder(filename, dict["borderColor"]));

                    if (hasPar("oilPaint"))
                        cd.addCommand(() => ImageManipulators.oilPaint(filename, dict["oilPaint"]));

                    if (hasPar("signature"))
                        cd.addCommand(() => ImageManipulators.signature(filename, dict["signature"]));

                    if (hasPar("toFileType"))
                        cd.addCommand(() => ImageManipulators.toFileType(filename, dict["toFileType"]));
                }
            }
            catch (System.ArgumentException) { printUsageHelp(); }
            catch (KeyNotFoundException) { /* This is not neccessarily bad */ }
        }
        public CommandDispatcher Initialize(params string[] args)
        {
            var dispatcher = new CommandDispatcher();

            var repository = new UserRepository();

            dispatcher.Handles<RegisterUser>(
                command => Logging.Log(command, () => CommandHandlers.Handle(command, repository)));

            return dispatcher;
        }
예제 #5
0
파일: Program.cs 프로젝트: jonte/ImgManip
        static void Main(string[] args)
        {
            // Set up logging
            log4net.Config.XmlConfigurator.Configure(); // use app.config

            log.Info("Starting run..");
            log.Info("Parsing arguments..");
            CommandDispatcher commandDispatcher = new CommandDispatcher();
            ArgumentsParser.parseArguments(args, commandDispatcher);

            log.Info("Executing commands..");
            commandDispatcher.executeAll();
        }
예제 #6
0
        public void UsernameWallPrintsWall()
        {
            var alice = new User("Alice");
            var retriever = new StubUserRetriever(alice);

            var spy = new PrintPostsSpy();
            var pSpy = new PublishPostSpy();
            var fSpy = new FollowUserSpy();
            var wSpy = new PrintWallSpy();
            var dispatcher = new CommandDispatcher(retriever, spy, pSpy, fSpy, wSpy);
            dispatcher.Run(new[] { "Alice", "wall" });

            Assert.Equal(alice, wSpy.LastCalledWith);
        }
예제 #7
0
        public void UsernameArrowMessagePublishesMessage()
        {
            var alice = new User("Alice");
            var retriever = new StubUserRetriever(alice);

            var spy = new PrintPostsSpy();
            var pSpy = new PublishPostSpy();
            var fSpy = new FollowUserSpy();
            var wSpy = new PrintWallSpy();
            var dispatcher = new CommandDispatcher(retriever, spy, pSpy, fSpy, wSpy);
            dispatcher.Run(new[] { "Alice", "->", "Hello,", "World!" });

            Assert.Equal(alice, pSpy.UserCalledWith);
            Assert.Equal("Hello, World!", pSpy.MessageCalledWith);
        }
예제 #8
0
        public void Dispatch_CallsResolverWithExpectedType()
        {
            bool wasCalledWithExpectedType = false;
              var commandDispatcher = new CommandDispatcher(t =>
              {
            if (t == typeof(ICommandHandler<ICommand>))
            {
              wasCalledWithExpectedType = true;
            }
            return _handler;
              });

              commandDispatcher.Dispatch(_command);

              Assert.That(wasCalledWithExpectedType, Is.True);
        }
        public void ShouldDispatchCommandWithoutParameters(
			string commandArgument,
			string scope,
			string commandName,
			[Frozen]Mock<ITypeNameMatcher> typeNameMatcher,
			[Frozen]Mock<IKernel> kernel,
			Mock<FooCommand> command,
			CommandDispatcher commandDispatcher)
        {
            typeNameMatcher.Setup(x => x.IsSatisfiedBy(commandArgument)).Returns(true);
            typeNameMatcher.Setup(x => x.GetMatchedType(commandArgument)).Returns(FooCommandType);
            kernel.Setup(x => x.Resolve(FooCommandType)).Returns(command.Object);

            commandDispatcher.Dispatch(new string[] { scope, commandName });

            command.Verify(x => x.Execute(It.Is<string[]>(y => !y.Any())));
        }
예제 #10
0
        public void TestSendCommand()
        {
            ObjectFactory.Initialize(registry =>
            {
                registry.Scan(x =>
                {
                    x.TheCallingAssembly();
                    x.AddAllTypesOf(typeof(ICommandHandler<>));
                    x.WithDefaultConventions();
                });
            });

            CommandDispatcher commandDispatcher = new CommandDispatcher();

            commandDispatcher.SendCommand(new AddUser { Name = "Steve", Password = "******" });
            commandDispatcher.SendCommand(new AddUser { Name = "Joe", Password = "******" });
        }
예제 #11
0
        static void Main()
        {
            Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);

              var dispatcher = new CommandDispatcher();

              try
              {
            Application.Run(dispatcher);
              }
              catch (Exception x)
              {
            dispatcher.Close();
            MessageBox.Show(x.Message, "FastFingers has encountered a critical error.", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
              }
        }
예제 #12
0
        public void UsernameFollowUsernameFollowsUser()
        {
            var alice = new User("Alice");
            var bob = new User("Bob");
            var repo = new UserRepository();
            repo.Add(alice);
            repo.Add(bob);
            var retriever = new CreateOrRetrieveUserByName(repo);

            var spy = new PrintPostsSpy();
            var pSpy = new PublishPostSpy();
            var fSpy = new FollowUserSpy();
            var wSpy = new PrintWallSpy();
            var dispatcher = new CommandDispatcher(retriever, spy, pSpy, fSpy, wSpy);
            dispatcher.Run(new[] { "Alice", "follows", "Bob" });

            Assert.Equal(alice, fSpy.UserCalledWith);
            Assert.Equal(bob, fSpy.UserToFollowCalledWith);
        }
        public void ShouldDispatchAliasCommandWithParameter(
			string commandArgument,
			string alias,
			string commandParameter,
			[Frozen]Mock<ITypeNameMatcher> typeNameMatcher,
			[Frozen]Mock<IAliasMatcher> aliasMatcher,
			[Frozen]Mock<IKernel> kernel,
			Mock<FooCommand> command,
			CommandDispatcher commandDispatcher)
        {
            typeNameMatcher.Setup(x => x.IsSatisfiedBy(It.IsAny<string>())).Returns(false);
            aliasMatcher.Setup(x => x.IsSatisfiedBy(alias)).Returns(true);

            aliasMatcher.Setup(x => x.GetMatchedType(alias)).Returns(FooCommandType);
            kernel.Setup(x => x.Resolve(FooCommandType)).Returns(command.Object);

            commandDispatcher.Dispatch(new string[] { alias, commandParameter });

            command.Verify(x => x.Execute(It.Is<string[]>(y => y.Length == 1 && y.Any(z => z == commandParameter))));
        }
        public void Dispatch_Command_With_ReturnValue()
        {
            //arrange
            var command = new TestCommandReturns();
            var commandHandler = MockRepository.GenerateMock<Handles<TestCommandReturns>>();
            commandHandler
                .Expect(handle => handle.Handle(command));

            ICommandDispatcher dispatcher = new CommandDispatcher();
            dispatcher.Register<TestCommandReturns>(commandHandler);

            //act
            dispatcher.Dispatch<TestCommandReturns>(command);

            //assert
            commandHandler.VerifyAllExpectations();

            //if we try to register the same command a second time we get an exception
            Assert.Throws<InvalidOperationException>(() => dispatcher.Register<TestCommandReturns>(commandHandler));
        }
        static void Main()
        {
            IInputReader consoleReader = new ConsoleReader();
            var consoleWriter = new ConsoleWriter
            {
                AutoFlush = true
            };

            IUnitContainer unitMatrix = new MatrixContainer(MatrixRows, MatrixCols);
            ICommandDispatcher commandDispatcher = new CommandDispatcher();
            IUnitEffector unitEffector = new EmptyUnitEffector();

            var engine = new Engine(unitMatrix,
                consoleReader,
                consoleWriter,
                commandDispatcher,
                unitEffector);

            engine.Start();
        }
        public void Start_SubscribesAndReceivesMessages()
        {
            var connectionString = ConfigurationManager.AppSettings["ServiceBus.ConnectionString"];
            var queueName = ConfigurationManager.AppSettings["CommandsQueueName"];

            var handlers = new List<ICommandHandler>();
            var repo = new Mock<IEventSourcedAggregateRepository>();
            var publisher = new Mock<IEventPublisher>();
            var logger = new Mock<ILogger>();

            var dispatcher = new CommandDispatcher(handlers, repo.Object, publisher.Object);

            var subscriber = new CommandQueueSubscriber(connectionString, queueName, dispatcher, logger.Object);

            subscriber.StartAsync();

            Thread.Sleep(60 * 1000);

            subscriber.Stop();
        }
        public void Submit_CallsHandlerSavesAndPublishesEvents()
        {
            var repo = new InMemoryEventSourcedRepository();
            var handler = new FakeCommandHandler(repo);
            var publisher = new Mock<IEventPublisher>();

            var dispatcher = new CommandDispatcher(new[] { handler }, repo, publisher.Object);

            var id = Guid.NewGuid();

            var updatedText = Guid.NewGuid().ToString();

            dispatcher.Submit(new CreateFakeAggregate { Id = id });
            dispatcher.Submit(new UpdateFakeAggregate { Id = id, Text = updatedText });

            var aggreate = repo.GetById<FakeAggregate>(id);

            Assert.AreEqual(updatedText, aggreate.Text);

            publisher.Verify(f => f.PublishEvent(It.Is<IEvent>(e => e.GetType() == typeof(FakeAggregateCreated))), Times.Once);
            publisher.Verify(f => f.PublishEvent(It.Is<IEvent>(e => e.GetType() == typeof(FakeAggregateUpdated))), Times.Once);
        }
예제 #18
0
 public ListProjectConfigurationBuildsCommand(CommandDispatcher commandDispatcher)
     : base(commandDispatcher)
 {
 }
예제 #19
0
 public virtual void ExecuteCommand(ICommand command)
 {
     CommandDispatcher.ExecuteCommand(command, null);
 }
예제 #20
0
        public Main()
        {
            InitializeComponent();

            Logger            = new Logger();
            CommandDispatcher = new CommandDispatcher(Logger);
            MessageHandler    = new MessageHandler(Logger);

            Logger.MessageLogged += delegate(string message)
            {
                if (this.Log.TextLength > 0)
                {
                    this.Log.AppendText("\n");
                }
                this.Log.AppendText(message);
                this.Log.ScrollToCaret();
            };

            Application.ThreadException +=
                delegate(object sender, ThreadExceptionEventArgs e)
            {
                this.Logger.Log("Unhandled Exception: " + e.Exception);
            };

            NotifyIcon.Icon = Icon;

            // Command and Message Handlers
            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (var type in assembly.GetTypes())
                {
                    if (!type.IsClass)
                    {
                        continue;
                    }
                    if (type.IsAbstract)
                    {
                        continue;
                    }

                    // Command Handlers
                    if (typeof(ICommandHandler).IsAssignableFrom(type))
                    {
                        var constructorInfo = type.GetConstructor(new Type[0] {
                        });
                        if (constructorInfo == null)
                        {
                            continue;
                        }

                        var commandHandler = constructorInfo.Invoke(null);
                        CommandDispatcher.AddCommandHandler((ICommandHandler)commandHandler);
                    }

                    // Message Handlers
                    if (typeof(IMessageSpanHandler).IsAssignableFrom(type))
                    {
                        var constructorInfo = type.GetConstructor(new Type[0] {
                        });
                        if (constructorInfo == null)
                        {
                            continue;
                        }

                        var messageSpanHandler = constructorInfo.Invoke(null);
                        MessageHandler.AddSpanHandler((IMessageSpanHandler)messageSpanHandler);
                    }
                }
            }

            // Skype
            Skype = new Skype();

            if (!Skype.Client.IsRunning)
            {
                Skype.Client.Start();
            }

            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "http://redd.it/1dko1n");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "https://www.youtube.com/watch?v=psuRGfAaju4");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "http://youtu.be/1uV63nApaYA");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "http://pastebin.com/8jNskG2r");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "http://pastebin.com/8jNskG2rasdsad");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "http://goo.gl/jmzTY");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "http://vimeo.com/61930364#");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "https://twitter.com/garrynewman/status/360042767461789698");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "https://twitter.com/thronecast/status/548132192988442624/photo/1");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "3000€");
            // this.MessageHandler.HandleMessage(x => Debug.Print(x), "£20");
            // this.CommandDispatcher.HandleMessage(x => Debug.Print(x), "!w asdfasdf");

            ConnectToSkype();
        }
예제 #21
0
        public async Task <ActionResult> Update(RecipeCategoryUpdateDto command)
        {
            await CommandDispatcher.DispatchAsync(command);

            return(NoContent());
        }
예제 #22
0
 public PaymentController(CommandDispatcher commandDispatcher, QueryDispatcher queryDispatcher, IResourceManager resourceManager
                          , PaymentService paymentService, IConfiguration configuration) : base(commandDispatcher, queryDispatcher, resourceManager)
 {
     _paymentService = paymentService;
     _configuration  = configuration;
 }
예제 #23
0
        public void Start()
        {
            const string queryString = "SELECT [ID],[Name],[WKN],[Multiplier],[StrikePrice],[Underlying],[InitialSL],[InitialTP],[PricePerUnit],[OrderCosts],[Description],[Units],[IsLong] FROM [dbo].[Calculations] ORDER BY [ID] ASC";
            const string countString = "SELECT COUNT([ID]) AS COUNT FROM [dbo].[Calculations]";

            //Load from db
            using (var connection = new SqlConnection(SourceConnectionString))
            {
                connection.Open();

                using (var command = new SqlCommand(countString, connection))
                {
                    var count = (int)command.ExecuteScalar();
                    LoggingService.Info($" ({count})");
                }

                using (var command = new SqlCommand(queryString, connection))
                {
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var item = new CalculationDto();

                            item.OldId        = int.Parse(reader["ID"].ToString());
                            item.Name         = reader["Name"].ToString();
                            item.Wkn          = reader["WKN"].ToString();
                            item.Multiplier   = decimal.Parse(reader["Multiplier"].ToString());
                            item.StrikePrice  = decimal.Parse(reader["StrikePrice"].ToString());
                            item.Underlying   = reader["Underlying"].ToString();
                            item.InitialSl    = decimal.Parse(reader["InitialSL"].ToString());
                            item.InitialTp    = decimal.Parse(reader["InitialTP"].ToString());
                            item.PricePerUnit = decimal.Parse(reader["PricePerUnit"].ToString());
                            item.OrderCosts   = decimal.Parse(reader["OrderCosts"].ToString());
                            item.Description  = reader["Description"].ToString();
                            item.Units        = decimal.Parse(reader["Units"].ToString());
                            item.IsLong       = bool.Parse(reader["IsLong"].ToString());

                            Items.Add(item.OldId, item);
                        }
                    }
                }
            }

            //Import
            foreach (var item in Items)
            {
                var cmd = new CalculationAddCommand(
                    item.Value.Id,
                    -1,
                    item.Value.Name,
                    item.Value.Wkn,
                    item.Value.Multiplier,
                    item.Value.StrikePrice,
                    item.Value.Underlying,
                    item.Value.InitialSl,
                    item.Value.InitialTp,
                    item.Value.PricePerUnit,
                    item.Value.OrderCosts,
                    item.Value.Description,
                    item.Value.Units,
                    item.Value.IsLong);

                CommandDispatcher.Execute(cmd);

                LoggingService.Info($"Calculation {item.Value.Name} ({item.Value.OldId})");
            }
        }
예제 #24
0
 public Session(CommandDispatcher dispatcher)
 {
     DefaultDispatcher = dispatcher;
 }
예제 #25
0
 public DscTests()
 {
     this.cmdSrv = new MulticastCommandServer(Guid.NewGuid().ToString());
     this.cmdDispatcher = new CommandDispatcher(Guid.NewGuid().ToString());
 }
        public void ShouldThrowDispatcherExceptionOnApiException(
			string commandArgument,
			[Frozen]Mock<ITypeNameMatcher> typeNameMatcher,
			[Frozen]Mock<IKernel> kernel,
			Mock<FooCommand> command,
			CommandDispatcher commandDispatcher)
        {
            typeNameMatcher.Setup(x => x.IsSatisfiedBy(commandArgument)).Returns(true);
            typeNameMatcher.Setup(x => x.GetMatchedType(It.IsAny<string>())).Returns(FooCommandType);
            kernel.Setup(x => x.Resolve(FooCommandType)).Returns(command.Object);

            command.Setup(x => x.Execute(new string[0])).Throws<ApiException>();

            Assert.Throws<DispatchException>(() => commandDispatcher.Dispatch(new string[] { commandArgument }));
        }
예제 #27
0
 public void Initialize()
 {
     this.unit       = new MockUnitOfWork();
     this.disptacher = new CommandDispatcher(unit);
 }
예제 #28
0
        public static IModelUI CreateBakeNodeInspector(this ElementBuilder elementBuilder, CommandDispatcher dispatcher, BakeNodeModel model)
        {
            var ui = UnityEditor.GraphToolsFoundation.Overdrive.ModelInspectorFactoryExtensions.CreateNodeInspector(elementBuilder, dispatcher, model);

            (ui as ModelUI)?.PartList.AppendPart(BakeNodeInspectorFields.Create("bake-node-fields", model, ui, ModelInspector.ussClassName));

            ui.BuildUI();
            ui.UpdateFromModel();

            return(ui);
        }
예제 #29
0
		private CommandHost GetCommandHost()
		{
			var dispatchers = new List<ICommandDispatcher>();
			var dispatcher = new CommandDispatcher(_locator, GetRegistry());

			dispatcher.Configure(_dispatcherSettings);

			dispatchers.Add(dispatcher);

			return new CommandHost(dispatchers);
		}
예제 #30
0
 protected BaseController(IResourceManager resourceManager, CommandDispatcher commandDispatcher, QueryDispatcher queryDispatcher)
 {
     _resourceManager   = resourceManager;
     _commandDispatcher = commandDispatcher;
     _queryDispatcher   = queryDispatcher;
 }
예제 #31
0
        public async Task <IActionResult> Put([FromBody] ChangeUserPassword command)
        {
            await CommandDispatcher.DispatchAsync(command);

            return(NoContent());
        }
예제 #32
0
 public CategoryController(QueryDispatcher queryDispatcher, CommandDispatcher commandDispatcher) : base(queryDispatcher, commandDispatcher)
 {
     _queryDispatcher   = queryDispatcher;
     _commandDispatcher = commandDispatcher;
 }
 private void CallButton_OnClick(object sender, RoutedEventArgs e)
 {
     CommandDispatcher.Call("101");
 }
예제 #34
0
 public DebugCommands(CommandDispatcher dispatcher)
 {
     _dispatcher = dispatcher;
 }
예제 #35
0
 public void ExecuteCommand(ICommand command, object argument)
 {
     CommandDispatcher.ExecuteCommand(command, argument);
 }
예제 #36
0
        public async Task <ActionResult> Create(RecipeCategoryCreateDto command)
        {
            await CommandDispatcher.DispatchAsync(command);

            return(Created($"api/recipecategories/{command.Name}", null));
        }
예제 #37
0
 public SynchronousCommandBusDecorator(ICommandBus commandBus)
 {
     this.commandBus        = commandBus;
     this.commandDispatcher = new CommandDispatcher();
 }
예제 #38
0
        public async Task <ActionResult> Delete([FromRoute] RecipeCategoryRemoveDto command)
        {
            await CommandDispatcher.DispatchAsync(command);

            return(NoContent());
        }
예제 #39
0
        public IEnumerator AlignNodesHierarchiesCommandWorks([Values] TestingMode mode)
        {
            var constantA = GraphModel.CreateConstantNode(typeof(int).GenerateTypeHandle(), "constantA", Vector2.zero);
            var binary0   = GraphModel.CreateNode <Type0FakeNodeModel>("Node1", Vector2.one * 200);
            var binary1   = GraphModel.CreateNode <Type0FakeNodeModel>("Node2", Vector2.one * 500);

            GraphModel.CreateEdge(binary0.Input0, constantA.OutputPort);
            GraphModel.CreateEdge(binary1.Input0, binary0.Output0);

            MarkGraphViewStateDirty();
            yield return(null);

            void RefreshModelReferences()
            {
                constantA = GraphModel.NodeModels[0] as IConstantNodeModel;
                binary0   = GraphModel.NodeModels[1] as Type0FakeNodeModel;
                binary1   = GraphModel.NodeModels[2] as Type0FakeNodeModel;

                Assert.IsNotNull(constantA);
                Assert.IsNotNull(binary0);
                Assert.IsNotNull(binary1);
            }

            yield return(TestPrereqCommandPostreq(mode,
                                                  () =>
            {
                RefreshModelReferences();

                Assert.That(binary0.Input0, Is.ConnectedTo(constantA.OutputPort));
                Assert.That(binary1.Input0, Is.ConnectedTo(binary0.Output0));

                var port0UI = binary0.Output0.GetUI <Port>(GraphView);
                Assert.IsNotNull(port0UI);
                var port1UI = binary1.Input0.GetUI <Port>(GraphView);
                Assert.IsNotNull(port1UI);
                Assert.AreNotEqual(GetPortY(port0UI), GetPortY(port1UI));

                var port2UI = constantA.OutputPort.GetUI <Port>(GraphView);
                Assert.IsNotNull(port2UI);
                var port3UI = binary0.Input0.GetUI <Port>(GraphView);
                Assert.IsNotNull(port3UI);
                Assert.AreNotEqual(GetPortY(port2UI), GetPortY(port3UI));
            },
                                                  frame =>
            {
                switch (frame)
                {
                case 0:
                    CommandDispatcher.Dispatch(new AlignNodesCommand(GraphView, true, binary1));
                    return TestPhase.WaitForNextFrame;

                default:
                    return TestPhase.Done;
                }
            },
                                                  () =>
            {
                RefreshModelReferences();

                var port0UI = binary0.Output0.GetUI <Port>(GraphView);
                Assert.IsNotNull(port0UI);
                var port1UI = binary1.Input0.GetUI <Port>(GraphView);
                Assert.IsNotNull(port1UI);
                Assert.AreEqual(GetPortY(port0UI), GetPortY(port1UI));

                var port2UI = constantA.OutputPort.GetUI <Port>(GraphView);
                Assert.IsNotNull(port2UI);
                var port3UI = binary0.Input0.GetUI <Port>(GraphView);
                Assert.IsNotNull(port3UI);
                Assert.AreEqual(GetPortY(port2UI), GetPortY(port3UI));
            }));
        }
예제 #40
0
 public NodeApiController(StudiesDatabase database, CommandDispatcher dispatcher)
 {
     _database   = database;
     _dispatcher = dispatcher;
 }
예제 #41
0
 public CommandDispatcher SetCommandDispatcher(CommandDispatcher dispatcher)
 {
     return Interlocked.Exchange(ref _commandDispatcher, dispatcher);
 }
예제 #42
0
 public void ExecuteCommand <TArgument>(ICommandWith <TArgument> command, TArgument argument)
 {
     CommandDispatcher.ExecuteCommand(command, argument);
 }
        public void ShouldThrowIfNoTypeMatcherAreSatisfied(string commandArgument,
			[Frozen]Mock<ITypeNameMatcher> typeNameMatcher,
			[Frozen]Mock<IAliasMatcher> aliasMatcher,
			CommandDispatcher commandDispatcher)
        {
            typeNameMatcher.Setup(x => x.IsSatisfiedBy(It.IsAny<string>())).Returns(false);
            aliasMatcher.Setup(x => x.IsSatisfiedBy(It.IsAny<string>())).Returns(false);

            Assert.Throws<DispatchException>(() => commandDispatcher.Dispatch(new string[] { commandArgument }));
        }
예제 #44
0
        public async Task <IActionResult> Post([FromBody] CreateUser command)
        {
            await CommandDispatcher.DispatchAsync(command);

            return(Created($"users/{command.Email}", new object()));
        }
예제 #45
0
		public BlogController(IDocumentSession documentSession, CommandDispatcher commandDispatcher)
		{
			_documentSession = documentSession;
			_commandDispatcher = commandDispatcher;
		}
예제 #46
0
        public CommandResult ExecuteCommand(Command command)
        {
            var commandDispatcher = new CommandDispatcher();

            return(commandDispatcher.Dispatch(command));
        }
 /// <inheritdoc />
 public ExtensionTestGraphView(GraphViewEditorWindow window, CommandDispatcher commandDispatcher, string graphViewName)
     : base(window, commandDispatcher, graphViewName)
 {
 }
예제 #48
0
 public ContextGraphView(ContextGraphViewWindow simpleGraphViewWindow, bool withWindowedTools, CommandDispatcher store) : base(simpleGraphViewWindow, store, "SimpleGraphView")
 {
     m_SimpleGraphViewWindow = simpleGraphViewWindow;
 }
        public void ShouldDispatchHelpWhenNoCommand(
			[Frozen]Mock<ITypeNameMatcher> typeNameMatcher,
			[Frozen]Mock<IKernel> kernel,
			Mock<FooCommand> command,
			CommandDispatcher commandDispatcher)
        {
            var helpArgument = "help";
            typeNameMatcher.Setup(x => x.IsSatisfiedBy(helpArgument)).Returns(true);
            typeNameMatcher.Setup(x => x.GetMatchedType(helpArgument)).Returns(FooCommandType);
            kernel.Setup(x => x.Resolve(FooCommandType)).Returns(command.Object);

            commandDispatcher.Dispatch(new string[0]);

            typeNameMatcher.VerifyAll();
        }
예제 #50
0
 public ProductController(CommandDispatcher commandDispatcher, QueryDispatcher queryDispatcher, IResourceManager resourceManager) : base(commandDispatcher, queryDispatcher, resourceManager)
 {
 }
 public static IModelUI CreateForPlacemat(this ElementBuilder elementBuilder,
                                          CommandDispatcher commandDispatcher, IPlacematModel model)
 {
     return(GraphViewFactoryExtensions.CreatePlacemat(elementBuilder, commandDispatcher, model));
 }
예제 #52
0
 public DefaultGraphView(BaseGraph _graph, CommandDispatcher _commandDispatcher, BaseGraphWindow _window) : base(_graph, _commandDispatcher, _window)
 {
 }
 public static IModelUI CreateForStickyNote(this ElementBuilder elementBuilder,
                                            CommandDispatcher commandDispatcher, IStickyNoteModel model)
 {
     return(GraphViewFactoryExtensions.CreateStickyNote(elementBuilder, commandDispatcher, model));
 }
 public static IModelUI CreateForStickyNote(this ElementBuilder elementBuilder,
                                            CommandDispatcher commandDispatcher, IStickyNoteModel model)
 {
     return(null);
 }
 public static IModelUI CreateForTestModel3(this ElementBuilder elementBuilder,
                                            CommandDispatcher commandDispatcher, TestModel3 model)
 {
     return(null);
 }
예제 #56
0
파일: Test.cs 프로젝트: Novakov/grupa.net
 public void SetUp()
 {
     this.dispatcher = new CommandDispatcher();
 }
예제 #57
0
		private void extractProcessorsFromAgents()
		{
			var commandHost = new CommandHost(new ICommandDispatcher[] { });

			foreach (var agent in Composite.Agents)
			{
				var processorAttribute = agent.AgentAssembly.GetAttributeValue<LocationOfProcessorsAttribute>();

				// SELF the Where call below changes the meaning of the rest of the registration so it had to be removed
				Container.Register(
					AllTypes.FromAssembly(agent.AgentAssembly)
						// .Where(Component.IsInNamespace(processorAttribute.Namespace))
						.BasedOn(typeof(ICommandProcessor)).Configure(c => c.LifeStyle.Transient).WithService.AllInterfaces().WithService.
						Self());

				var registry = Container.Resolve<ICommandRegistry>();

				var dispatcher = new CommandDispatcher(new WindsorServiceLocator(Container), registry);

				var dispatcherSettings = new MessageDispatcherSettings();

				dispatcherSettings.InputChannel.WithDefault(CurrentSettings.InputChannel.Value);
				dispatcherSettings.InvalidChannel.WithDefault(CurrentSettings.ErrorChannel.Value);

				var processors = Container.ResolveAll(typeof(ICommandProcessor));

				foreach (var processor in processors)
				{
					dispatcherSettings.MessageProcessorTypes.Add(processor.GetType());
				}

				dispatcher.Configure(dispatcherSettings);

				commandHost.AddDispatcher(dispatcher);
			}

			Container.Register(Component.For<IHostedService>().Instance(commandHost).Forward<CommandHost>().LifeStyle.Transient);
		}