Exemple #1
0
 public CommandSketch(CommandAttribute attribute, Type commandType, Func <ICommand> locator)
 {
     this.Arguments   = ReflectionTools.GetArgumentsDescription(commandType);
     this.Attribute   = attribute;
     this.CommandType = commandType;
     this._locator    = locator;
 }
Exemple #2
0
        public Instruction Create(List <string> args)
        {
            string cmdName = ParseTools.ExtractCommandName(args);

            var description = library.GetOrNull(cmdName);

            if (description == null)
            {
                throw new UnknownCommandNameException(cmdName);
            }

            var intervalArgumentsDescription
                = ReflectionTools.GetArgumentsDescription(typeof(CommandScheduleSettings));
            var intervalSettingsValues = ReflectionTools.ExtractAndParse(args, intervalArgumentsDescription, typeof(CommandScheduleSettings));
            var intervalSettings       = new CommandScheduleSettings();

            ReflectionTools.Configurate(intervalSettings, intervalSettingsValues);

            var commandConfiguration = ReflectionTools.ExtractAndParse(args, description.Arguments, description.CommandType);

            if (args.Count != 0)
            {
                throw new UnknownArgumentsException(args.ToArray());
            }

            return(new Instruction {
                Locator = new CommandLocator(description.GetRawInstance, commandConfiguration),
                ScheduleSettings = intervalSettings,
            });
        }