예제 #1
0
        /// <summary>
        /// Returns configurated and ready for execution exemplar of a command
        /// </summary>
        public ICommand GetReadyToGoInstance()
        {
            var ans = _instanceLocator();

            ReflectionTools.Configurate(ans, _configuration);
            return(ans);
        }
예제 #2
0
파일: Interpreter.cs 프로젝트: tmteam/Gin
        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,
            });
        }