private void ParseHeaderFile(string aPath, Encoding aCodePage) { using (var idParser = new HeaderParser(aPath, aCodePage)) { while (idParser.HasNext()) { var obj = idParser.GetNext(); IDTrimmer.TrimEnd(obj.ID); IDNormalizer.NormalizeRecurrenceForID(obj.ID, mHeaderContent); if (!IDValidator.IsValidWithoutRecurrenceCheck(obj.ID)) { continue; } mHeaderContent.NameToID[obj.Name] = new HeaderId(obj.ID); IDNormalizer.NormalizeHexaID(obj.ID); if (!mHeaderContent.SortedHeaderResults.ContainsKey(aPath)) { mHeaderContent.SortedHeaderResults.Add(aPath, new List <HeaderItem>()); } mHeaderContent.SortedHeaderResults[aPath].Add(obj); } if (mHeaderContent.SortedHeaderResults.ContainsKey(aPath)) { mHeaderContent.SortedHeaderResults[aPath].Sort(new HeaderResultComparerByID()); } } }
public static HeaderId NormalizeRecurrenceForID(HeaderId aID, HeaderContent aHeaderContent) { while (IDValidator.IsRecurrentCase(aID, aHeaderContent)) { aID.Value = aHeaderContent.NameToID[aID.Value].Value; } if (!IDValidator.IsValidWithoutRecurrenceCheck(aID)) { aID.Value = Constants.kInvalidID.Value; } return(aID); }
public static HeaderId NormalizeHexaID(HeaderId aID) { if (!IDValidator.IsInValidRange(aID)) { aID.Value = Constants.kInvalidID.Value; } if (IDValidator.IsHexaRepresentation(aID)) { aID.Value = Convert.ToInt32(aID.Value, 16).ToString(); } if (!IDValidator.IsValidInteger(aID)) { aID.Value = Constants.kInvalidID.Value; } return(aID); }