/// <summary> /// Invokes the specified command. /// </summary> /// <param name="command">The command.</param> public void Invoke(T command) { var context = new ValidationContext(command, null, null); var results = new List <ValidationResult>(); var isValid = Validator.TryValidateObject(command, context, results); if (!isValid) { throw new CommandValidationFailedException(command, results); } _inner.Invoke(command); }
/// <summary> /// Invokes the specified command. /// </summary> /// <param name="command">The command.</param> public void Invoke(T command) { try { _inner.Invoke(command); } catch (Exception err) { var parameters = new Dictionary <string, object>(); foreach (PropertyInfo propertyInfo in command.GetType().GetProperties()) { object value = propertyInfo.GetValue(command, null); parameters.Add(propertyInfo.Name, value); } var info = new CommandExceptionInfo(command.GetType().Name, parameters, err); _logger.Log(info); throw; } }