/// <summary> /// Returns configurated and ready for execution exemplar of a command /// </summary> public ICommand GetReadyToGoInstance() { var ans = _instanceLocator(); ReflectionTools.Configurate(ans, _configuration); return(ans); }
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, }); }