public void CreateCommand(string commandName, ICompositeCommand compositeCommand = null,
bool throwExceptionWhenCommandIsAlreadyCreated = true)
{
Argument.IsNotNullOrWhitespace("commandName", commandName);
lock (_lockObject)
{
Log.Debug("Creating command '{0}'", commandName);
if (_commands.ContainsKey(commandName))
{
var error = string.Format("Command '{0}' is already created using the CreateCommand method", commandName);
Log.Error(error);
if (throwExceptionWhenCommandIsAlreadyCreated)
{
throw new InvalidOperationException(error);
}
return;
}
if (compositeCommand == null)
{
compositeCommand = new CompositeCommand();
}
_commands.Add(commandName, compositeCommand);
InvalidateCommands();
CommandCreated.SafeInvoke(this, () => new CommandCreatedEventArgs(compositeCommand, commandName));
}
}
#endif