/** * @brief Scans a project location of file and fills the BBCodeBase. * @param fileName is path to a directory or a single file. * @param bbCodeBase clears all entries in this object and adds the new entries. * @return true on successful scan. */ private static bool ScanSingleFile(string fileName, ref BBCodeBase bbCodeBase) { try { // Open the file as text. StreamReader sr = File.OpenText(fileName); // Iterate all lines until the end. string lineText; int lineNumber = 0; while (!sr.EndOfStream) { // Read single line. lineText = sr.ReadLine(); lineNumber++; // Try to parse the line with descriptor parser. Result is not null if successful. BBCodeObject bbCode = BBCodeDescriptorParser.Parse(lineText, fileName, lineNumber); // Add to the database (only if not null). bbCodeBase.AddBBCode(bbCode); } // Close the file. sr.Close(); // Everything is OK. return(true); } catch { } // Problem occured. return(false); }
public List <BBCodeFormatPrimitive> formatPrimitiveArray; ///< List of format primitives that are described in the description of the format string. /** * @brief Constructor. * @param shortCode 2-letter short code to identify the message. * @param formatString Format descriptor string. * @param sourceFile Source file that has descriptor for this BBCodeObject. * @param sourceFileLine Line number of the source file */ public BBCodeObject(string shortCode, string formatString, string sourceFile, int sourceFileLine) { // Assign direct values. this.shortCode = shortCode; this.formatString = formatString; this.sourceFile = sourceFile; this.sourceFileLine = sourceFileLine; // Fill the format primitive list using the parser. this.formatPrimitiveArray = BBCodeDescriptorParser.ParseFormatString(formatString); }