Exemplo n.º 1
0
        public void Save(string fileName)
        {
            try
            {
                //Create a new XmlTextWriter.
                //				XmlTextWriter xwriter = new XmlTextWriter(Console.Out);
                var xwriter = new XmlTextWriter(fileName, System.Text.Encoding.UTF8);
                xwriter.Formatting  = Formatting.None;
                xwriter.IndentChar  = '\t';
                xwriter.Indentation = 1;

                //Write the beginning of the document including the
                //document declaration. Standalone is true.

                xwriter.WriteStartDocument(true);

                //Write the beginning of the "data" element. This is
                //the opening tag to our data

                xwriter.WriteWhitespace("\n");
                xwriter.WriteStartElement("parameters");
                xwriter.WriteWhitespace("\n\t");
                xwriter.WriteElementString("version", "1.0");
                xwriter.WriteWhitespace("\n\t");

                this.PeakProcessorParameters.SaveV1PeakParameters(xwriter);
                this.DTAGenerationParameters.SaveV1DTAGenerationParameters(xwriter);
                this.HornTransformParameters.SaveV1HornTransformParameters(xwriter);
                this.HornTransformParameters.SaveV1MiscellaneousParameters(xwriter);
                if (FTICRPreProcessParameters.IsToBePreprocessed)
                {
                    FTICRPreProcessParameters.SaveV1FTICRPreProcessOptions(xwriter);
                }

                // And the isotope abundances.
                HornTransformParameters.ElementIsotopeComposition.SaveV1ElementIsotopes(xwriter);

                xwriter.WriteEndElement();

                //End the document
                xwriter.WriteEndDocument();
                xwriter.WriteWhitespace("\n");

                //Flush the xml document to the underlying stream and
                //close the underlying stream. The data will not be
                //written out to the stream until either the Flush()
                //method is called or the Close() method is called.
                xwriter.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(PRISM.clsStackTraceFormatter.GetExceptionStackTraceMultiLine(ex));
            }
        }
Exemplo n.º 2
0
        public void Load(string xmlFileName)
        {
            this.ParameterFilename = xmlFileName;

            var rdr = new XmlTextReader(xmlFileName);

            //Read each node in the tree.
            while (rdr.Read())
            {
                switch (rdr.NodeType)
                {
                case XmlNodeType.Element:
                    if (rdr.Name == "PeakParameters")
                    {
                        PeakProcessorParameters.LoadV1PeakParameters(rdr);
                    }
                    else if (rdr.Name == "HornTransformParameters")
                    {
                        HornTransformParameters.LoadV1HornTransformParameters(rdr);

                        if (HornTransformParameters.NumScansToAdvance == 0)
                        {
                            HornTransformParameters.NumScansToAdvance = 1;
                        }
                    }
                    else if (rdr.Name == "Miscellaneous")
                    {
                        HornTransformParameters.LoadV1MiscellaneousParameters(rdr);
                    }
                    else if (rdr.Name == "FTICRRawPreProcessingOptions")
                    {
                        FTICRPreProcessParameters.LoadV1FTICRPreProcessOptions(rdr);
                    }
                    else if (rdr.Name == "ElementIsotopes")
                    {
                        HornTransformParameters.ElementIsotopeComposition.LoadV1ElementIsotopes(rdr);
                    }
                    else if (rdr.Name == "DTAGenerationParameters")
                    {
                        DTAGenerationParameters.LoadV1DTAGenerationParameters(rdr);
                    }
                    break;

                default:
                    break;
                }
            }
            rdr.Close();
        }