Esempio n. 1
0
 public static void EndLineCheck(ForParse attribute)
 {
     if (attribute.wordIndex + 1 > (Parser.wordsCount == null ? 0 : Parser.wordsCount))
     {
         Throw.UnexpectedEndException(new ForException {
             wrongWordAt   = attribute.wordIndex,
             wrongLetterAt = 0,
             //letter = ' ',
             sentence           = attribute.sentence,
             sentenceForMessage = attribute.sentenceForMessage,
             //expectedWord = attribute.separator
         });
     } //Конец строки
 }
Esempio n. 2
0
        public static void ParseUserAccessParamName(ForParse attribute)
        {
            EndLineCheck(new ForParse {
                wordIndex          = attribute.wordIndex,
                sentence           = attribute.sentence,
                sentenceForMessage = Term.Name.ToLower() + " " + WordInMessage.SystemUserParam
            });

            if (!CommonDict.UserAccessParamNameList.Contains(Parser.words[attribute.wordIndex]))
            {
                Throw.WrongUserAccesstParamName(new ForException {
                    wrongWordAt = attribute.wordIndex,
                    found       = Parser.words[attribute.wordIndex]
                });
            }
        }
Esempio n. 3
0
        public static void ParseName(ForParse attribute)
        {
            int i = 0;

            EndLineCheck(new ForParse {
                wordIndex          = attribute.wordIndex,
                sentence           = attribute.sentence,
                sentenceForMessage = Term.Name.ToLower() + " " + attribute.sentenceForMessage
            });
            //attribute, Termi.Name.ToLower() + " " + attribute.sentenceForMessage);

            if (!CommonDict.alphabet.Contains(Parser.words[attribute.wordIndex].ToLower()[i]))
            {
                Throw.WrongNameException(new ForException {
                    wrongWordAt        = attribute.wordIndex,
                    wrongWordLength    = Parser.words[attribute.wordIndex].Length,
                    wrongLetterAt      = i,
                    letter             = Parser.words[attribute.wordIndex][i],
                    sentence           = attribute.sentence,
                    sentenceForMessage = attribute.sentenceForMessage
                });
                //Throw.WrongNameException(attribute.wordIndex, i, Parse.words[attribute.wordIndex][i], attribute.sentence, attribute.sentenceForMessage);
            }
            else
            {
                foreach (char c in Parser.words[attribute.wordIndex].ToLower())
                {
                    if (!CommonDict.alphabetWithNumbers.Contains(c))
                    {
                        Throw.WrongNameException(new ForException {
                            wrongWordAt        = attribute.wordIndex,
                            wrongWordLength    = Parser.words[attribute.wordIndex].Length,
                            wrongLetterAt      = i,
                            letter             = Parser.words[attribute.wordIndex][i],
                            sentence           = attribute.sentence,
                            sentenceForMessage = attribute.sentenceForMessage,
                            previousWord       = Parser.words[attribute.wordIndex].Substring(0, i)
                        });
                    }
                    i++;
                }
            }
        }
Esempio n. 4
0
        public static void ParseID(ForParse attribute)
        {
            int i = 0;

            EndLineCheck(new ForParse {
                wordIndex          = attribute.wordIndex,
                sentence           = attribute.sentence,
                sentenceForMessage = Term.ID + " " + attribute.sentenceForMessage
            });

            foreach (char c in Parser.words[attribute.wordIndex])
            {
                if (!CommonDict.numeric.Contains(c))
                {
                    if (i == 0)
                    {
                        Throw.WrongIDException(new ForException {
                            wrongWordAt        = attribute.wordIndex,
                            wrongWordLength    = Parser.words[attribute.wordIndex].Length,
                            wrongLetterAt      = i,
                            letter             = Parser.words[attribute.wordIndex][i],
                            sentence           = attribute.sentence,
                            sentenceForMessage = attribute.sentenceForMessage
                        });
                    }
                    else
                    {
                        Throw.WrongIDException(new ForException {
                            wrongWordAt        = attribute.wordIndex,
                            wrongWordLength    = Parser.words[attribute.wordIndex].Length,
                            wrongLetterAt      = i,
                            letter             = Parser.words[attribute.wordIndex][i],
                            sentence           = attribute.sentence,
                            sentenceForMessage = attribute.sentenceForMessage,
                            previousWord       = Parser.words[attribute.wordIndex].Substring(0, i)
                        });
                    }
                }
                i++;
            }
        }
Esempio n. 5
0
        public static void IsObjectInSystem(DAM.Model.System system, ForParse attribute)
        {
            EndLineCheck(new ForParse {
                wordIndex          = attribute.wordIndex,
                sentence           = attribute.sentence,
                sentenceForMessage = Term.ID.ToLower() + " " + WordInMessage.SystemObject
            });

            Parser.ParseID(new ForParse {
                wordIndex          = attribute.wordIndex,
                sentence           = Sentence.SystemObject,
                sentenceForMessage = WordInMessage.SystemObject
            });     //ID объекта
            if (!system.Objects.Any(x => x.ID == Convert.ToUInt32(Parser.words[attribute.wordIndex])))
            {
                Throw.NoSuchObject(new ForException {
                    wrongWordAt = attribute.wordIndex,
                    found       = Parser.words[attribute.wordIndex]
                });
            }
        }
Esempio n. 6
0
 public static void ParseSeparator(ForParse attribute)
 {
     EndLineCheck(new ForParse {
         wordIndex          = attribute.wordIndex,
         sentence           = attribute.sentence,
         separator          = attribute.separator,
         sentenceForMessage = $"{Term.Separator.ToLower()} \"{attribute.separator}\" после {attribute.sentenceForMessage}"
     });
     if (!Parser.words[attribute.wordIndex].Equals(attribute.separator))
     {
         Throw.WrongSeparatorException(new ForException {
             wrongWordAt        = attribute.wordIndex,
             wrongWordLength    = Parser.words[attribute.wordIndex].Length,
             wrongLetterAt      = 0,
             letter             = Parser.words[attribute.wordIndex][0],
             sentence           = attribute.sentence,
             sentenceForMessage = attribute.sentenceForMessage,
             expectedWord       = attribute.separator,
             previousWord       = Parser.words[attribute.wordIndex - 1]
         });
         //Throw.WrongSeparatorException(attribute.wordIndex, 0, Parse.words[attribute.wordIndex][0], attribute.sentence, attribute.sentenceForMessage, attribute.separator, attribute.previousWord);
     }
 }