Beispiel #1
0
        public bool TryParse(string solutionFile, out SolutionFile result)
        {
            Validate.IsNotNull(solutionFile, nameof(solutionFile));
            SolutionFileBuilder sfb = new SolutionFileBuilder();

            result = null;
            string[] strArray = solutionFile.Split(new string[2]
            {
                "\n",
                "\r\n"
            },
                                                   StringSplitOptions.RemoveEmptyEntries);
            sfb.SetLineCount(strArray.Length);
            sfb.SetSizeInChars(solutionFile.Length);
            ILineParser lineParser1   = null;
            bool        needMoreLines = false;

            foreach (string str in strArray)
            {
                string line = str.Trim();
                if (lineParser1 == null)
                {
                    foreach (ILineParser lineParser2 in lineParsers)
                    {
                        if (lineParser2.TryParseLine(line, sfb, out needMoreLines))
                        {
                            if (needMoreLines)
                            {
                                lineParser1 = lineParser2;
                            }

                            break;
                        }
                    }
                }
                else if (lineParser1.TryParseLine(line, sfb, out needMoreLines))
                {
                    if (!needMoreLines)
                    {
                        lineParser1 = null;
                    }
                }
                else
                {
                    sfb.SetIsValid(false);
                    break;
                }
            }

            if (needMoreLines)
            {
                sfb.SetIsValid(false);
            }

            result = sfb.Build();
            return(result.IsValid);
        }