Пример #1
0
        /// <summary>
        /// Appends details about this change to the XML file
        /// </summary>
        public void ExportToXml(XmlTextWriter xmlWriter, StringDictionary nameMap)
        {
            string displayName;

            xmlWriter.WriteStartElement("entry");

            xmlWriter.WriteStartElement("date");
            string outputDateFormat = "yyyy'-'MM'-'dd";

            xmlWriter.WriteString(date.ToString(outputDateFormat));
            xmlWriter.WriteEndElement();

            xmlWriter.WriteStartElement("time");
            string outputTimeFormat = "HH':'mm";

            xmlWriter.WriteString(date.ToString(outputTimeFormat));
            xmlWriter.WriteEndElement();

            xmlWriter.WriteStartElement("author");
            // Check if we have the authors real name
            if (nameMap.ContainsKey(author))
            {
                displayName = nameMap[author];
            }
            else
            {
                // no - just display the authors user ID
                displayName = author;
            }
            xmlWriter.WriteCData(displayName);
            xmlWriter.WriteEndElement();

            foreach (object o in fileRevisions)
            {
                FileRevision fileRevision = (FileRevision)o;
                fileRevision.ExportToXml(xmlWriter);
            }

            if (comment != null && comment.Length != 0)
            {
                xmlWriter.WriteStartElement("msg");
                xmlWriter.WriteCData(comment);
                xmlWriter.WriteEndElement();
            }

            xmlWriter.WriteEndElement();    // "file"
        }
Пример #2
0
        public void Serialise()
        {
            string filename         = "testfile.cs";
            string revision         = "1.4";
            string previousRevision = "1.3";

            FileRevision fileRevision = new FileRevision(filename, revision, previousRevision);

            MemoryStream  stream = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(stream, new System.Text.UTF8Encoding());

            // Serialise the FileRevision to a memory stream as XML
            writer.WriteStartDocument();
            writer.WriteStartElement("test");
            fileRevision.ExportToXml(writer);
            writer.WriteEndElement();    // test
            writer.WriteEndDocument();
            writer.Flush();
//            writer.Close();

            // rewind and check what was written
            stream.Position = 0;

            XmlTextReader reader = new XmlTextReader(stream);

//            while (reader.Read())
//            {
//            System.Console.WriteLine("{0}-{1}-{2}", reader.NodeType, reader.Value, reader.Name);
//            }

            // the xml declaration
            reader.Read();
            Assert.AreEqual(XmlNodeType.XmlDeclaration, reader.NodeType);

            // the root element
            reader.Read();
            Assert.AreEqual(XmlNodeType.Element, reader.NodeType);

            Check(reader, "testfile.cs", "1.4", "1.3");

            // the end of the root element
            reader.Read();
            Assert.AreEqual(XmlNodeType.EndElement, reader.NodeType);
            Assert.AreEqual("test", reader.Name);
        }
Пример #3
0
 	/// <summary>
 	/// Adds details about a file revision to the entry
 	/// </summary>
 	public void AddFileRevision(string fnm, string revision, string previousRevision) {
 	    FileRevision fileRevision = new FileRevision(fnm, revision, previousRevision);
 	    fileRevisions.Add(fileRevision);
 	}
Пример #4
0
        /// <summary>
        /// Adds details about a file revision to the entry
        /// </summary>
        public void AddFileRevision(string fnm, string revision, string previousRevision)
        {
            FileRevision fileRevision = new FileRevision(fnm, revision, previousRevision);

            fileRevisions.Add(fileRevision);
        }