public static void ExtractRequirements()

in traceabilitytool/reportgenerator.cs [282:327]


        public static void ExtractRequirements(string filePath, string pattern, string text, ref Dictionary<string, string> reqLookup)
        {
            int count = 0;
            foreach (Match m in Regex.Matches(text, pattern))
            {
                count++;
                // Add each requirement from Word documents to the lookup dictionary
                // unless this requirement already exists.
                if (reqLookup.ContainsKey(m.Value))
                {
                    // Requirement already exists.  Put it in the dictionary of repeating requirements.
                    List<string> filePaths;

                    if (repeatingRequirements.ContainsKey(m.Value))
                    {
                        // Update the existing list of file paths.
                        filePaths = repeatingRequirements[m.Value];
                    }
                    else
                    {
                        // Create a new list of file paths.
                        filePaths = new List<string>();

                        // Add the file path from the dictionary first (original document path), then add the current path.
                        filePaths.Add(reqLookup[m.Value]);
                    }
                    // Add the new path for the repeating requirement.
                    filePaths.Add(filePath);
                    // Add all paths to the dictionary.
                    repeatingRequirements.Add(m.Value, filePaths);

                    if (m.Value.Length > repeatingRequirementsKeyWidth)
                        repeatingRequirementsKeyWidth = m.Value.Length;
                }
                else
                {
                    // Create a new entry with requirement ID as the key and the path as the value to the dictionary.
                    reqLookup.Add(m.Value, filePath);
                }
            }
            if (count > 0)
            {
                reqDocCount.Add(filePath, count);
            }

        }