Пример #1
0
 /// <summary>
 /// Writes the specified matches to <see cref="OutputFile" />.
 /// </summary>
 /// <param name="matches">The collection of matches to write.</param>
 private void WriteMatches(MatchCollection matches) {
     WriteMethod writeMethod = new WriteMethod(this.WriteXml);
     using (StreamWriter writer = new StreamWriter(OutputFile.FullName)) {
         writeMethod(matches, writer);
     }
 }
Пример #2
0
        /// <summary>
        /// Performs the regex-search.
        /// </summary>
        protected override void ExecuteTask() {
            MatchCollection matches = new MatchCollection();
            Pattern pattern = new Pattern(Pattern);

            Log(Level.Info, "Writing matches to '{0}'.", OutputFile.FullName);

            foreach (string filename in InputFiles.FileNames ) {
                using (StreamReader reader = new StreamReader(filename)) {
                    string fileContent = reader.ReadToEnd();
                    matches.Add(pattern.Extract(filename, fileContent));
                }
            }

            WriteMatches(matches);
        }
Пример #3
0
 /// <summary>
 /// Writes the collection of matches to the specified <see cref="StreamWriter" />
 /// in XML format.
 /// </summary>
 /// <param name="matches">The matches to write.</param>
 /// <param name="writer"><see cref="StreamWriter" /> to write the matches to.</param>
 private void WriteXml(MatchCollection matches, StreamWriter writer) {
     XmlTextWriter xmlWriter = new XmlTextWriter(writer);
     xmlWriter.WriteStartDocument();
     xmlWriter.WriteStartElement("Matches");
     foreach (Match match in matches) {
         match.WriteXml(xmlWriter);
     }
     xmlWriter.WriteEndElement();
     xmlWriter.WriteEndDocument();
 }
Пример #4
0
 /// <summary>
 /// Adds all <see cref="Match"/> instances <paramref name="matches" />
 /// to this collection.
 /// </summary>
 /// <param name="matches">Collection of <see cref="Match" /> instances to add.</param>
 public void Add(MatchCollection matches)
 {
     foreach (Match match in matches) {
         this.Add(match);
     }
 }