예제 #1
0
 public void Validate(IArgsMapper mapper, Command command)
 {
     if (mapper.Options.HasPositionalOption())
     {
         throw new CommandConflictsWithPositionalOptionException();
     }
 }
예제 #2
0
 public void Validate(IArgsMapper mapper, Option option)
 {
     foreach (var validator in Validators)
     {
         validator.Validate(mapper, option);
     }
 }
예제 #3
0
 public void Validate(IArgsMapper mapper, Option option)
 {
     if (!_valueConverterFactory.IsSupportedBaseType(option.Type))
     {
         throw new UnsupportedOptionPropertyTypeException(option.Type);
     }
 }
 public void Validate(IArgsMapper mapper, Option option)
 {
     if (option.IsPositionalOption && mapper.Commands.Any())
     {
         throw new PositionalOptionConflictsWithCommandException();
     }
 }
 public void Validate(IArgsMapper mapper, Command command)
 {
     foreach (var validator in Validators)
     {
         validator.Validate(mapper, command);
     }
 }
예제 #6
0
 public void Validate(IArgsMapper mapper, Option option)
 {
     if (mapper.Options.Any(x => string.Equals(x.LongName, option.LongName, mapper.Settings.StringComparison)))
     {
         throw new OptionLongNameAlreadyExistsException(option.LongName);
     }
 }
 public void Validate(IArgsMapper mapper, Command command)
 {
     if (mapper.Commands.Any(x => string.Equals(x.Name, command.Name, _argsMapperSettings.StringComparison)))
     {
         throw new CommandNameAlreadyExistsException(command.Name);
     }
 }
예제 #8
0
        public void Validate(IArgsMapper mapper, Command command)
        {
            if (string.IsNullOrEmpty(command.Name) || string.IsNullOrWhiteSpace(command.Name))
            {
                throw new CommandNameRequiredException(command.PropertyInfo);
            }

            if (!command.HasValidName())
            {
                throw new InvalidCommandNameException(command.Name);
            }
        }
예제 #9
0
        public void Validate(IArgsMapper mapper, Option option)
        {
            if (!option.HasShortName)
            {
                return;
            }

            if (mapper.Options.Where(x => x.HasShortName).Any(x => x.ShortName == option.ShortName))
            {
                // ReSharper disable once PossibleInvalidOperationException
                throw new OptionShortNameAlreadyExistsException(option.ShortName.Value);
            }
        }
        public void Validate(IArgsMapper mapper, Option option)
        {
            // ReSharper disable once InvertIf
            if (option.HasShortName)
            {
                // ReSharper disable once PossibleInvalidOperationException
                if (!char.IsLetter(option.ShortName.Value))
                {
                    throw new InvalidOptionShortNameException(option.ShortName.Value);
                }

                if (option.ShortName.Value.IsReservedOptionShortName())
                {
                    throw new ReservedOptionShortNameException(option.ShortName.Value);
                }
            }
        }
        public void Validate(IArgsMapper mapper, Option option)
        {
            if (string.IsNullOrEmpty(option.LongName) || string.IsNullOrWhiteSpace(option.LongName))
            {
                throw new OptionLongNameRequiredException(option.PropertyInfo);
            }

            if (!option.HasValidLongName())
            {
                throw new InvalidOptionLongNameException(option.LongName);
            }

            if (option.LongName.IsReservedOptionLongName())
            {
                throw new ReservedOptionLongNameException(option.LongName);
            }
        }
        public void Validate(IArgsMapper mapper, Option option)
        {
            // ReSharper disable once InvertIf
            if (option.IsPositionalOption)
            {
                if (mapper.Options.Any(x => x.IsPositionalOption && x.Type.IsList()))
                {
                    throw new PositionalOptionListConflictException();
                }

                // ReSharper disable once InvertIf
                if (option.Type.IsList())
                {
                    if (mapper.Options.Any(x => x.IsPositionalOption))
                    {
                        throw new PositionalOptionListConflictException();
                    }
                }
            }
        }
예제 #13
0
 internal ArgumentMapper(IArgsMapper mapper, IReflectionService reflectionService)
 {
     _mapper = mapper;
     _reflectionService = reflectionService;
 }