/// <summary> /// Creates the command inside the command manager. /// <para /> /// If the <paramref name="throwExceptionWhenCommandIsAlreadyCreated"/> is <c>false</c> and the command is already created, only /// the input gesture is updated for the existing command. /// </summary> /// <param name="commandName">Name of the command.</param> /// <param name="inputGesture">The input gesture.</param> /// <param name="compositeCommand">The composite command. If <c>null</c>, this will default to a new instance of <see cref="CompositeCommand" />.</param> /// <param name="throwExceptionWhenCommandIsAlreadyCreated">if set to <c>true</c>, this method will throw an exception when the command is already created.</param> /// <exception cref="ArgumentException">The <paramref name="commandName" /> is <c>null</c> or whitespace.</exception> /// <exception cref="InvalidOperationException">The specified command is already created using the <see cref="CreateCommand" /> method.</exception> 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)); } }
/// <summary> /// Creates the command inside the command manager. /// </summary> /// <param name="commandName">Name of the command.</param> /// <param name="compositeCommand">The composite command. If <c>null</c>, this will default to a new instance of <see cref="CompositeCommand"/>.</param> /// <param name="throwExceptionWhenCommandIsAlreadyCreated">if set to <c>true</c>, this method will throw an exception when the command is already created.</param> /// <exception cref="ArgumentException">The <paramref name="commandName" /> is <c>null</c> or whitespace.</exception> /// <exception cref="InvalidOperationException">The specified command is already created using the <see cref="CreateCommand" /> method.</exception> 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)); } }
public IClassifierDataSourceHandler.EvaluationResult EvaluateEvent(CommandCreated eventToEvaluate) { // Created commands are in process return(IClassifierDataSourceHandler.EvaluationResult.Include); }