示例#1
0
 public char?GetShortName(IShortNameArgument arg, string errorMessage)
 {
     if (arg.ShortName.HasValue)
     {
         if (!ArgumentValidation.IsAllowedShortName(arg.ShortName.Value))
         {
             throw new ArgumentIntegrityException(errorMessage);
         }
         return(arg.ShortName.Value);
     }
     return(null);
 }
示例#2
0
        private static Exception LongNameArgumentMustBeValidCharacter(IArgument arg)
        {
            var sh = arg as ILongNameArgument;

            if (sh != null &&
                sh.LongName != null &&
                !ArgumentValidation.IsAllowedLongName(sh.LongName))
            {
                return(new ArgumentIntegrityException(String.Format(
                                                          "Invalid argument {0}: {1}", sh.LongName,
                                                          ArgumentValidation.IsAllowedLongNameExplanation)));
            }
            return(null);
        }
示例#3
0
        private Exception ShortNameArgumentMustBeValidCharacter(IArgument arg)
        {
            var sh = arg as IShortNameArgument;

            if (sh != null &&
                sh.ShortName.HasValue &&
                !ArgumentValidation.IsAllowedShortName(sh.ShortName.Value))
            {
                return(new ArgumentIntegrityException(String.Format(
                                                          "Invalid argument {0}: {1}", sh.ShortName,
                                                          ArgumentValidation.IsAllowedShortNameExplanation)));
            }
            return(null);
        }
示例#4
0
        public string GetLongName(ILongNameArgument arg, string errorMessage)
        {
            if (arg.LongName != null)
            {
                if (arg.LongName.Length < 2)
                {
                    throw new ArgumentIntegrityException(String.Format(
                                                             "Long argument {0} must have at least two characters.",
                                                             arg.LongName));
                }
                if (!ArgumentValidation.IsAllowedLongName(arg.LongName))
                {
                    throw new ArgumentIntegrityException(errorMessage);
                }
                return(arg.LongName);
            }

            return(null);
        }