public CommandLineArgumentInterpreter(ICommandProvider commandProvider, ICommandNameMatcher commandNameMatcher, ICommandArgumentParser commandArgumentParser, ICommandArgumentNameMatcher commandArgumentNameMatcher)
 {
     this.commandProvider = commandProvider;
     this.commandNameMatcher = commandNameMatcher;
     this.commandArgumentParser = commandArgumentParser;
     this.commandArgumentNameMatcher = commandArgumentNameMatcher;
 }
        /// <summary>
        /// Registers the argument parsers and all others that are in the same assembly and namespace.
        /// </summary>
        /// <param name="argumentParserType">The type of the <see cref="ICommandArgumentParser"/> to register.</param>
        public void AddArgumentParsersAt(Type argumentParserType)
        {
            if (argumentParserType == null)
            {
                throw new ArgumentNullException(nameof(argumentParserType), "'argumentParserType' cannot be null.");
            }

            Type baseType = typeof(ICommandArgumentParser);

            if (!baseType.IsAssignableFrom(argumentParserType))
            {
                throw new ArgumentException("'argumentParserType' needs to implement the ICommandArgumentParser interface.", nameof(argumentParserType));
            }

            IEnumerable <Type> argumentParserTypes = argumentParserType.Assembly
                                                     .GetTypes()
                                                     .Where(t =>
                                                            t.Namespace == argumentParserType.Namespace &&
                                                            baseType.IsAssignableFrom(t) &&
                                                            t.GetConstructors().Any(ctor => ctor.GetParameters().Length == 0));

            lock (_syncRoot)
            {
                foreach (Type siblingArgumentParserType in argumentParserTypes)
                {
                    ICommandArgumentParser siblingArgumentParser = (ICommandArgumentParser)Activator.CreateInstance(siblingArgumentParserType);
                    AddArgumentParserInternal(siblingArgumentParser);
                }
            }
        }
		public CommandParser(ICommandConfigurationRegistry commandConfigurationRegistry,
		                     ICommandFactory commandFactory,
		                     ICommandArgumentParser commandArgumentParser)
		{
			_commandConfigurationRegistry = commandConfigurationRegistry;
			_commandFactory = commandFactory;
			_commandArgumentParser = commandArgumentParser;
		}
        private void AddArgumentParserInternal(ICommandArgumentParser argumentParser)
        {
            if (_argumentParsers.ContainsKey(argumentParser.ResultType))
            {
                throw new ArgumentException("An argument parser of the same type has already been added.", nameof(argumentParser));
            }

            _argumentParsers.Add(argumentParser.ResultType, argumentParser);
        }
        /// <summary>
        /// Adds an argument parser to the collection.
        /// </summary>
        /// <param name="argumentParser">The instance of the argument parser to add.</param>
        /// <exception cref="ArgumentNullException"><paramref name="argumentParser"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">An argument parser of the same type has already been added.</exception>
        public void AddArgumentParser(ICommandArgumentParser argumentParser)
        {
            if (argumentParser == null)
            {
                throw new ArgumentNullException(nameof(argumentParser), "'argumentParser' cannot be null.");
            }

            lock (_syncRoot)
            {
                AddArgumentParserInternal(argumentParser);
            }
        }
        /// <summary>
        /// Adds an argument parser to the collectiion.
        /// </summary>
        /// <param name="argumentParserType">Type of the argument parser to add.</param>
        /// <exception cref="ArgumentNullException"><paramref name="argumentParserType"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="argumentParserType"/> does not implement the <see cref="ICommandArgumentParser"/> interface
        /// or an argument parser of the same type has already been added.
        /// </exception>
        public void AddArgumentParser(Type argumentParserType)
        {
            if (argumentParserType == null)
            {
                throw new ArgumentNullException(nameof(argumentParserType), "'argumentParserType' cannot be null.");
            }
            if (!typeof(ICommandArgumentParser).IsAssignableFrom(argumentParserType))
            {
                throw new ArgumentException("'argumentParserType' needs to implement the ICommandArgumentParser interface.", nameof(argumentParserType));
            }

            ICommandArgumentParser argumentParser = (ICommandArgumentParser)Activator.CreateInstance(argumentParserType);

            lock (_syncRoot)
            {
                AddArgumentParserInternal(argumentParser);
            }
        }
 public void Setup()
 {
     this.commandArgumentParser = new CommandArgumentParser();
 }
        public void Setup()
        {
            var userInterfaceMock = new Mock<IUserInterface>();
            var solutionPackagingServiceMock = new Mock<ISolutionPackagingService>();
            var buildPropertyParser = new Mock<IBuildPropertyParser>();
            var publishingService = new Mock<IPublishingService>();

            this.packackageSolutionCommand = new PackageSolutionCommand(userInterfaceMock.Object, solutionPackagingServiceMock.Object, buildPropertyParser.Object, publishingService.Object);

            this.commands = new List<ICommand> { this.packackageSolutionCommand };

            this.commandProvider = new ConsoleCommandProvider(this.commands);
            this.commandNameMatcher = new CommandNameMatcher();
            this.commandArgumentParser = new CommandArgumentParser();
            this.commandArgumentNameMatcher = new CommandArgumentNameMatcher();

            this.commandLineArgumentInterpreter = new CommandLineArgumentInterpreter(
                this.commandProvider, this.commandNameMatcher, this.commandArgumentParser, this.commandArgumentNameMatcher);
        }
		public CommandArgumentParserTests()
		{
			_commandArgumentParser = new CommandArgumentParser(_reflectionPropertyBinderFactory.Object,
			                                                   _parameterExtractorMock.Object);
		}