public void CheckPBSequence() { int pagenoInt; List<string> validpage = new List<string>(File.ReadAllLines(string.Concat(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.AppSettings["validpage"].ToString()))); int prevPbNo = 0; bool isRoman = false; foreach (XElement pb in this._xdoc.Descendants("text").Descendants<XElement>("pb")) { try { string pagenoStr = pb.Attribute("n").Value; if (int.TryParse(pagenoStr, out pagenoInt)) { if ((prevPbNo == 0 ? false : pagenoInt != prevPbNo + 1)) { List<ErrorModel> errorlist = this.Errorlist; ErrorModel errorModel = new ErrorModel() { LineNumber = ((IXmlLineInfo)pb).LineNumber, ErrorMessage = "Incorrect page number", Text = pagenoStr }; errorlist.Add(errorModel); } if (isRoman) { prevPbNo = 0; } isRoman = false; prevPbNo = pagenoInt; } else { if (RomanNumeralUtility.TryConvertToArabic(pagenoStr, out pagenoInt)) { if (!isRoman) { prevPbNo = 0; } isRoman = true; } else if (!validpage.Contains(pagenoStr)) { List<ErrorModel> errorModels = this.Errorlist; ErrorModel errorModel1 = new ErrorModel() { LineNumber = ((IXmlLineInfo)pb).LineNumber, ErrorMessage = "Incorrect page number", Text = pagenoStr }; errorModels.Add(errorModel1); } prevPbNo = 0; } } catch (NullReferenceException nullReferenceException) { } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)