public XDocument[] Process (params XDocument[] documents) { if (documents.Length != 1) throw new ArgumentException ("You have to pass only one document.","documents"); XDocument document = documents[0]; List<XDocument> results = new List<XDocument> (); var filesToWrite = from file in document.Root.Element ("files").Elements () select file.Attribute ("Name").Value.Split (',')[0]; foreach (var file in filesToWrite) { XDocument generatedDocument = CreateDocument (); //TODO: Extract some methods in order to preserve //the coherence generatedDocument.Add (new XElement ("gendarme-output", new XAttribute ("date", document.Root.Attribute("date").Value))); generatedDocument = AddFilesSection (generatedDocument, file, document.Root.Element ("files")); generatedDocument.Root.Add (document.Root.Element ("rules")); generatedDocument = AddResultsSection (generatedDocument, file, document.Root.Element ("results")); results.Add (generatedDocument); if (writeAction == null) writeAction = new WriteToFileAction (String.Format ("{0}.xml", file)); writeAction.DestinationFile = String.Format ("{0}.xml", file); writeAction.Process (generatedDocument); } return results.ToArray (); }
public XDocument[] Process (params XDocument[] documents) { if (documents.Length != 1) throw new ArgumentException ("You have to pass only one document.", "documents"); XDocument document = documents[0]; string assemblyName = (from file in document.Root.Element ("files").Elements () select file.Attribute ("Name").Value.Split (',')[0]).First (); XDocument critical = CloneDocument (document); XDocument high = CloneDocument (document); XDocument medium = CloneDocument (document); XDocument low = CloneDocument (document); RemoveDefectsWithoutSeverity (Critical, critical); RemoveDefectsWithoutSeverity (High, high); RemoveDefectsWithoutSeverity (Medium, medium); RemoveDefectsWithoutSeverity (Low, low); if (writeAction == null) writeAction = new WriteToFileAction (String.Format ("{0}.Critical.xml", assemblyName)); WriteToFile (String.Format ("{0}.Critical.xml", assemblyName), critical); WriteToFile (String.Format ("{0}.High.xml", assemblyName), high); WriteToFile (String.Format ("{0}.Medium.xml", assemblyName), medium); WriteToFile (String.Format ("{0}.Low.xml", assemblyName), low); return new XDocument[] {critical, high, medium, low}; }