Exemplo n.º 1
0
 internal string Execute(ICommand command, CommandParameterCollection args, CommandSettingCollection settings, ICommandContext context)
 {
     if (!ParseArgs(args))
         throw new CommandParameterException("Failed to parse the arguments.", command, args);
     try
     {
         return ExecuteCommand(settings, context);
     }
     catch (Exception e)
     {
         throw new CommandException(command, e);
     }
 }
Exemplo n.º 2
0
            private bool ParseArgs(CommandParameterCollection args)
            {
                object arg;

                if (args == null || args.Count != 2) return false;

                if (!args.TryGetParameter("Message", typeof(string), true, out arg)) return false;
                _message = Convert.ToString(arg);

                if (!args.TryGetParameter("RepeatCount", typeof(int), false, out arg)) return false;
                _repeatCount = Convert.ToInt32(arg);

                return true;
            }
Exemplo n.º 3
0
 /// <summary>
 /// Method execution logic.
 /// </summary>
 /// <param name="args">The arguments.</param>
 /// <param name="context">The context.</param>
 /// <param name="settings">The settings.</param>
 /// <returns></returns>
 public object Execute(CommandParameterCollection args, CommandSettingCollection settings, ICommandContext context)
 {
     return new CommandProcessor().Execute(this, args, settings, context);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandParameterException" /> class.
 /// </summary>
 /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
 /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
 /// <exception cref="T:System.ArgumentNullException">The <paramref name="info" /> parameter is null.</exception>
 /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult" /> is zero (0).</exception>
 protected CommandParameterException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _parameters = (CommandParameterCollection)info.GetValue("Parameters", typeof(CommandParameterCollection));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandParameterException" /> class.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="command">The command.</param>
 /// <param name="passedParameters">The passed parameters.</param>
 /// <param name="inner">The inner exception.</param>
 public CommandParameterException(string message, ICommand command, CommandParameterCollection passedParameters, Exception inner)
     : base(message, command, inner)
 {
     _parameters = passedParameters;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandParameterException" /> class.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="passedParameters">The passed parameters.</param>
 /// <param name="inner">The inner exception.</param>
 public CommandParameterException(ICommand command, CommandParameterCollection passedParameters, Exception inner)
     : base(command, inner)
 {
     _parameters = passedParameters;
 }