public void CreateCommand(string commandName, InputGesture inputGesture = null, ICompositeCommand compositeCommand = null,
bool throwExceptionWhenCommandIsAlreadyCreated = true)
{
Argument.IsNotNullOrWhitespace("commandName", commandName);
lock (_lockObject)
{
Log.Debug("Creating command '{0}' with input gesture '{1}'", commandName, ObjectToStringHelper.ToString(inputGesture));
if (_commands.ContainsKey(commandName))
{
var error = $"Command '{commandName}' is already created using the CreateCommand method";
Log.Error(error);
if (throwExceptionWhenCommandIsAlreadyCreated)
{
throw new InvalidOperationException(error);
}
_commandGestures[commandName] = inputGesture;
return;
}
if (compositeCommand == null)
{
compositeCommand = new CompositeCommand();
}
_commands.Add(commandName, compositeCommand);
_originalCommandGestures.Add(commandName, inputGesture);
_commandGestures.Add(commandName, inputGesture);
CommandCreated.SafeInvoke(this, () => new CommandCreatedEventArgs(compositeCommand, commandName));
}
}
#else