示例#1
0
        public Stream Format(XDoc doc)
        {
            // TODO (steveb): convert XML to VERSIT without generating a string first
            var bytes = MimeType.TEXT.CharSet.GetBytes(VersitUtil.ToVersit(doc));

            return(new MemoryStream(bytes));
        }
示例#2
0
        public void VersitSerialization()
        {
            XDoc cal = new XDoc("icalendar");

            cal.Start("vcalendar");
            cal.Start("prodid").Value("-//MindTouch//Deki//Calendar//EN").End();
            cal.Start("version").Value("1.0").End();
            cal.Start("vevent");
            cal.Start("dtstart").Value(new DateTime(2006, 9, 1, 16, 30, 0, DateTimeKind.Utc)).End();
            cal.Start("dtend").Value(new DateTime(2006, 9, 1, 17, 15, 0, DateTimeKind.Utc)).End();
            cal.Start("location").Attr("encoding", "QUOTED-PRINTABLE").Value("Joe's Office").End();
            cal.Start("uid").Value("264665-2").End();
            cal.Start("categories").Attr("encoding", "QUOTED-PRINTABLE").Value("Meeting").End();
            cal.Start("summary").Attr("encoding", "QUOTED-PRINTABLE").Value("Meeting: status & pizza").End();
            cal.Start("description").Value("Please show-up on time.\n\nPizzas will be ordered after meeting.").End();
            cal.Start("priority").Value("2").End();
            cal.End();
            cal.End();

            string text     = VersitUtil.ToVersit(cal);
            string expected =
                "BEGIN:VCALENDAR\r\n" +
                "PRODID:-//MindTouch//Deki//Calendar//EN\r\n" +
                "VERSION:1.0\r\n" +
                "BEGIN:VEVENT\r\n" +
                "DTSTART:20060901T163000Z\r\n" +
                "DTEND:20060901T171500Z\r\n" +
                "LOCATION;ENCODING=QUOTED-PRINTABLE:Joe's Office\r\n" +
                "UID:264665-2\r\n" +
                "CATEGORIES;ENCODING=QUOTED-PRINTABLE:Meeting\r\n" +
                "SUMMARY;ENCODING=QUOTED-PRINTABLE:Meeting: status & pizza\r\n" +
                "DESCRIPTION:Please show-up on time.\\n\\nPizzas will be ordered after meeting.\r\n" +
                "PRIORITY:2\r\n" +
                "END:VEVENT\r\n" +
                "END:VCALENDAR\r\n";

            Assert.AreEqual(expected, text, "versit did not match");
        }
示例#3
0
        public void VersitDeserialization()
        {
            string versit =
                "BEGIN:VCALENDAR\r\n" +
                "PRODID:-//MindTouch//Deki//Calendar//EN\r\n" +
                "VERSION:1.0\r\n" +
                "BEGIN:VEVENT\r\n" +
                "DTSTART:20060902T063000Z\r\n" +
                "DTEND:20060902T071500Z\r\n" +
                "LOCATION;ENCODING=QUOTED-PRINTABLE:Joe's Office\r\n" +
                "UID:264665-2\r\n" +
                "CATEGORIES;ENCODING=QUOTED-PRINTABLE:Meeting\r\n" +
                "SUMMARY;ENCODING=QUOTED-PRINTABLE:Meeting: status & pizza\r\n" +
                "DESCRIPTION:Please show-up on time.\\n\\n\r\n" +
                " Pizzas will be ordered after meeting.\r\n" +
                "PRIORITY:2\r\n" +
                "END:VEVENT\r\n" +
                "END:VCALENDAR\r\n";

            string text     = VersitUtil.FromVersit(versit, "icalendar").ToString();
            string expected = "<icalendar><vcalendar><prodid>-//MindTouch//Deki//Calendar//EN</prodid><version>1.0</version><vevent><dtstart>2006-09-02T06:30:00Z</dtstart><dtend>2006-09-02T07:15:00Z</dtend><location encoding=\"QUOTED-PRINTABLE\">Joe's Office</location><uid>264665-2</uid><categories encoding=\"QUOTED-PRINTABLE\">Meeting</categories><summary encoding=\"QUOTED-PRINTABLE\">Meeting: status &amp; pizza</summary><description>Please show-up on time.\n\nPizzas will be ordered after meeting.</description><priority>2</priority></vevent></vcalendar></icalendar>";

            Assert.AreEqual(expected, text, "versit-xml did not match");
        }