Ejemplo n.º 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));
        }
Ejemplo n.º 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");
        }