RegisterAction() публичный Метод

Registers the action with the specified command name.
The is null or whitespace. The is null. The specified command is not created using the method.
public RegisterAction ( string commandName, System.Action action ) : void
commandName string Name of the command.
action System.Action The action.
Результат void
Пример #1
0
            public void RegisteredActionsCanBeUnregistered_DynamicAction()
            {
                var commandManager = new CommandManager();

                commandManager.CreateCommand("TestAction");

                commandManager.RegisterAction("TestAction", RegisteredActionsCanBeUnregistered_TestMethod);
                commandManager.UnregisterAction("TestAction", RegisteredActionsCanBeUnregistered_TestMethod);

                commandManager.ExecuteCommand("TestAction");

                Assert.IsFalse(_registeredActionsCanBeUnregistered_TestValue);
            }
Пример #2
0
            public void RegisteredActionsCanBeUnregistered_DefinedAction()
            {
                var invoked = false;
                Action action = () => invoked = true;

                var commandManager = new CommandManager();

                commandManager.CreateCommand("TestAction");

                commandManager.RegisterAction("TestAction", action);
                commandManager.UnregisterAction("TestAction", action);

                commandManager.ExecuteCommand("TestAction");

                Assert.IsFalse(invoked);
            }