Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="writer"></param>
 /// <returns></returns>
 public bool WriteXmlHeader(XmlTextWriter writer)
 {
     // <entry char="g" value="103" time="63604023814.284" />
     writer.WriteStartElement("Entry");
     writer.WriteAttributeString("char", XmlConvert.ToString(this.Char));
     writer.WriteAttributeString("value", XmlConvert.ToString(this.Code));
     writer.WriteAttributeString("ticks", XmlConvert.ToString(this.Ticks));
     writer.WriteAttributeString("seconds", XmlConvert.ToString(TimeEx.Ticks2Sec(this.Ticks, 2)));
     writer.WriteEndElement(); // </Entry>
     return(true);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes this session object out as an XML log, which can be read in at a later time to
        /// "re-inflate" this session object.
        /// </summary>
        /// <param name="writer"></param>
        /// <returns>True if successful; false otherwise.</returns>
        public bool WriteXmlHeader(XmlTextWriter writer)
        {
            bool success = true;

            try
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument(true);
                writer.WriteStartElement("TextTest");
                Version v = Assembly.GetExecutingAssembly().GetName().Version;
                writer.WriteAttributeString("version", String.Format("{0}.{1}.{2}", v.Major, v.Minor, v.Build));
                writer.WriteAttributeString("trials", XmlConvert.ToString(this.NumTrials));
                writer.WriteAttributeString("ticks", XmlConvert.ToString(this.Ticks));
                writer.WriteAttributeString("seconds", XmlConvert.ToString(TimeEx.Ticks2Sec(this.Ticks, 2)));
                DateTime dt = new DateTime(this.Ticks);
                writer.WriteAttributeString("date", String.Format("{0} {1}", dt.ToLongDateString(), dt.ToLongTimeString()));

                // write out the individual trials
                for (int i = 0; i < this.NumTrials; i++)
                {
                    _trials[i].WriteXmlHeader(writer);
                    _trials[i].WriteXmlFooter(writer);
                }

                writer.WriteEndDocument(); // </TextTest>
            }
            catch (XmlException xex)
            {
                Console.WriteLine(xex);
                success = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                success = false;
            }
            return(success);
        }