Ejemplo n.º 1
0
        public override void WriteXml(XmlWriter writer)
        {
            // Write tag attributes
            base.WriteXml(writer);
            writer.WriteAttribute(ATTR.use_for_retention_time_prediction, false);
            writer.WriteAttributeNullable(ATTR.analyte_concentration, AnalyteConcentration);
            if (null != SampleType && !Equals(SampleType, SampleType.DEFAULT))
            {
                writer.WriteAttribute(ATTR.sample_type, SampleType.Name);
            }

            // Write optimization element, if present
            if (OptimizationFunction != null)
            {
                IXmlElementHelper <OptimizableRegression> helper = XmlUtil.FindHelper(
                    OptimizationFunction, OPTIMIZATION_HELPERS);
                if (helper == null)
                {
                    throw new InvalidOperationException(Resources.ChromatogramSet_WriteXml_Attempt_to_serialize_list_containing_invalid_type);
                }
                writer.WriteElement(helper.ElementNames[0], OptimizationFunction);
            }

            int i = 0;

            foreach (var fileInfo in MSDataFileInfos)
            {
                writer.WriteStartElement(EL.sample_file);
                writer.WriteAttribute(ATTR.id, GetOrdinalSaveId(i++));
                writer.WriteAttribute(ATTR.file_path, fileInfo.FilePath);
                writer.WriteAttribute(ATTR.sample_name, fileInfo.FilePath.GetSampleOrFileName());
                if (fileInfo.RunStartTime != null)
                {
                    writer.WriteAttribute(ATTR.acquired_time, XmlConvert.ToString((DateTime)fileInfo.RunStartTime, "yyyy-MM-ddTHH:mm:ss"));  // Not L10N
                }
                if (fileInfo.FileWriteTime != null)
                {
                    writer.WriteAttribute(ATTR.modified_time, XmlConvert.ToString((DateTime)fileInfo.FileWriteTime, "yyyy-MM-ddTHH:mm:ss")); // Not L10N
                }
                writer.WriteAttribute(ATTR.has_midas_spectra, fileInfo.HasMidasSpectra, false);

                // instrument information
                WriteInstrumentConfigList(writer, fileInfo.InstrumentInfoList);

                writer.WriteEndElement();
            }
            SrmDocument.WriteAnnotations(writer, Annotations);
        }