/** * Parses a manifest file (or manifest override file) and populates this parser's list of ManifestEntries. * @throws FileNotFoundException If the manifest file does not exist. * @throws IOException If the manifest file cannot be read. * @throws ExParser If a line cannot be parsed. * @throws ExManifest If a ManifestEntry is invalid in the context of the manifest. */ public void parse() { StreamReader lReader = null; try { lReader = new StreamReader(mManifestFile.FullName); string lLine; int lHighestSequencePosition = 0; Dictionary <string, int> lFileIndexes = new Dictionary <string, int>(); while ((lLine = lReader.ReadLine()) != null) { //Trim whitespace lLine = lLine.Trim(); //Skip empty lines if (string.IsNullOrEmpty(lLine)) { continue; } //Skip comment lines if (lLine[0] == '#') { continue; } //Attempt to parse the line as a property line (this will return null if it is not) Dictionary <string, string> lPromotionPropertyMap = parsePromotionPropertiesLine(lLine); if (lPromotionPropertyMap != null) { Logger.logDebug("Parsed promotion property line"); if (mPromotionPropertyMap != null) { //Only one definition allowed per manifest throw new ExParser("Duplicate PROMOTION definition line found"); } mPromotionPropertyMap = lPromotionPropertyMap; continue; } //Assume any other line is a manifest entry (this will error if it is not) ManifestEntry lManifestEntry = parseManifestEntryLine(lLine, lHighestSequencePosition); lHighestSequencePosition = lManifestEntry.getSequencePosition(); mManifestEntryList.Add(lManifestEntry); if (!lManifestEntry.isForcedDuplicate()) { mFinalProcessedFilePathSet.Add(lManifestEntry.getFilePath()); } //Record the index of the file int lFileIndex; if (!lFileIndexes.TryGetValue(lManifestEntry.getFilePath(), out lFileIndex)) { lFileIndex = 1; } else { lFileIndex++; } lManifestEntry.setFileIndex(lFileIndex); lFileIndexes.Add(lManifestEntry.getFilePath(), lFileIndex); //Construct a new loader if necessary createLoaderIfUndefined(lManifestEntry.getLoaderName()); Logger.logDebug("Parsed manifest entry for " + lManifestEntry.getFilePath()); } } finally { //Close the reader to release the lock on the file lReader?.Close(); } }
/** * Parses a line of a manifest file into a ManifestEntry. * @param pLine Line of file to be parsed. * @param pCurrentSequencePosition * @return A new ManifestEntry. * @throws ExParser If the line cannot be parsed into a ManifestEntry. * @throws ExManifest If the ManifestEntry is invalid in the context of this manifest. */ protected ManifestEntry parseManifestEntryLine(string pLine, int pCurrentSequencePosition) { return(ManifestEntry.parseManifestFileLine(pLine, false)); }