Esempio n. 1
0
        private void GetParameterAndTypeFromArg(string arg, int colonIndex)
        {
            string nameFromArg = arg.Substring(1, colonIndex - 1);
            string textFromArg = arg.Substring(colonIndex + 1, arg.Length - 1);

            if ((nameFromArg.Length > 0) && (textFromArg.Length > 0))
            {
                CheckIfNameIsAllowedAndNotDuplicate(nameFromArg, textFromArg);
            }
            else
            {
                if (nameFromArg.Length < 1)
                {
                    ArgError newError = new ArgError(ArgErrorTypes.EmptyType);
                    HandleError(newError);
                }

                if (textFromArg.Length < 1)
                {
                    ArgError newError = new ArgError(ArgErrorTypes.EmptyText);
                    HandleError(newError);
                }
            }
        }
Esempio n. 2
0
        private void CheckIfNameIsAllowedAndNotDuplicate(string namePassed, string textPassed)
        {
            bool typeIsAllowed = false;
            bool typeIsNotDuplicate = true;

            foreach (string item in allowedParameters)
            {
                if (item == namePassed)
                {
                    typeIsAllowed = true;
                    continue;
                }
            }
            foreach (ParameterBase item in parameters)
            {
                if (item.Name == namePassed)
                {
                    typeIsNotDuplicate = false;
                    continue;
                }
            }

            if ((typeIsAllowed) && (typeIsNotDuplicate))
            {
                CreateNewParameter(namePassed, textPassed);
            }
            else
            {
                if (typeIsAllowed)
                {
                    ArgError newError = new ArgError(ArgErrorTypes.ArgTypeIsDuplicate);
                    HandleError(newError);
                }
                else
                {
                    ArgError newError = new ArgError(ArgErrorTypes.ArgTypeNotAllowed);
                    HandleError(newError);
                }
            }
        }
Esempio n. 3
0
 private void CheckArgLength(string arg)
 {
     if (arg.Length == 0)
     {
         ArgError newError = new ArgError(ArgErrorTypes.Empty);
         HandleError(newError);
     }
     else
     {
         CheckArgForLeadingHyphen(arg);
     }
 }
Esempio n. 4
0
 private void CheckArgForNull(string arg)
 {
     if (arg == null)
     {
         ArgError newError = new ArgError(ArgErrorTypes.Null);
         HandleError(newError);
     }
     else
     {
         CheckArgLength(arg);
     }
 }
Esempio n. 5
0
 private void CheckArgForLeadingHyphen(string arg)
 {
     int lastHyphenIndex = arg.LastIndexOf('-');
     if (lastHyphenIndex == -1)
     {
         ArgError newError = new ArgError(ArgErrorTypes.NoHyphen);
         HandleError(newError);
     }
     else if (lastHyphenIndex > 0)
     {
         ArgError newError = new ArgError(ArgErrorTypes.MultipleHyphens);
         HandleError(newError);
     }
     else
     {
         CheckArgForColon(arg);
     }
 }
Esempio n. 6
0
 private void CheckArgForColon(string arg)
 {
     int firstColonIndex = arg.IndexOf(':');
     int lastColonIndex = arg.LastIndexOf(':');
     if (firstColonIndex == -1)
     {
         ArgError newError = new ArgError(ArgErrorTypes.NoColon);
         HandleError(newError);
     }
     else if (firstColonIndex != lastColonIndex)
     {
         ArgError newError = new ArgError(ArgErrorTypes.MultipleColons);
         HandleError(newError);
     }
     else
     {
         GetParameterAndTypeFromArg(arg, firstColonIndex);
     }
 }