public override object Serialize(CISinkSerializationParameters aParams) { CXmlFileDocument document = new CXmlFileDocument(); //Read information relevant to crash info file from container to internal variables document.ReadDataFromContainer(aParams); string newFileName = ""; if (aParams.PlainTextOutput) { //Override default file extension aParams.FileExtensionFailed = ".corrupt_txt"; aParams.FileExtensionSuccess = ".txt"; //Write document's internal data to file newFileName = string.Empty; using (Stream output = aParams.CreateFile(out newFileName)) { using (StreamWriter sw = new StreamWriter(output, Encoding.ASCII)) { document.WriteToPlainTextStream(sw); } } } else // XML output { //Override default file extension aParams.FileExtensionFailed = ".corrupt_xml"; aParams.FileExtensionSuccess = ".xml"; //Write document's internal data to file newFileName = string.Empty; using (Stream output = aParams.CreateFile(out newFileName)) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.NewLineChars = XmlConsts.Kxml_EOL; settings.NewLineHandling = NewLineHandling.None; using (XmlWriter sw = XmlWriter.Create(output, settings)) { document.WriteToXmlStream(sw); } } } return(newFileName); }
public override object Serialize(CISinkSerializationParameters aParams) { CCrashInfoFileDocument document = new CCrashInfoFileDocument(); //Read information relevant to crash info file from container to internal variables document.ReadDataFromContainer(aParams); //Override default file extension aParams.FileExtensionFailed = ".corrupt_ci"; aParams.FileExtensionSuccess = ".ci"; //Write document's internal data to file string newFileName = string.Empty; using (Stream output = aParams.CreateFile(out newFileName)) { using (StreamWriter sw = new StreamWriter(output, Encoding.ASCII)) { document.WriteToStream(sw); } } return(newFileName); }