当前位置: 首页>>代码示例>>C#>>正文


C# iCalendarSerializer.SerializeToString方法代码示例

本文整理汇总了C#中DDay.iCal.Serialization.iCalendarSerializer.SerializeToString方法的典型用法代码示例。如果您正苦于以下问题:C# iCalendarSerializer.SerializeToString方法的具体用法?C# iCalendarSerializer.SerializeToString怎么用?C# iCalendarSerializer.SerializeToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DDay.iCal.Serialization.iCalendarSerializer的用法示例。


在下文中一共展示了iCalendarSerializer.SerializeToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteFile

        protected override void WriteFile(System.Web.HttpResponseBase response)
        {
            iCalendar iCal = new iCalendar();
            foreach (Dinner d in this.Dinners)
            {
                try
                {
                    Event e = CalendarHelpers.DinnerToEvent(d, iCal);
                    iCal.Events.Add(e);
                }
                catch (ArgumentOutOfRangeException)
                {
                    //Swallow folks that have dinners in 9999.
                }
            }

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            string result = serializer.SerializeToString();
            response.ContentEncoding = Encoding.UTF8;
            response.Write(result);
        }
开发者ID:jasonlin,项目名称:dapperDinner,代码行数:21,代码来源:iCalResult.cs

示例2: SERIALIZE18

        public void SERIALIZE18()
        {
            iCalendar iCal = new iCalendar();

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event title";
            evt.Start = new Date_Time(2007, 3, 19);
            evt.Start.Kind = DateTimeKind.Utc;
            evt.Duration = new TimeSpan(24, 0, 0);
            evt.Created = evt.Start.Copy();
            evt.DTStamp = evt.Start.Copy();
            evt.UID = "123456789";
            evt.IsAllDay = true;            

            Recur rec = new Recur("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4");
            evt.AddRecurrence(rec);

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            string icalString = serializer.SerializeToString();

            Assert.IsNotEmpty(icalString, "iCalendarSerializer.SerializeToString() must not be empty");

            ComponentBaseSerializer compSerializer = new ComponentBaseSerializer(evt);
            string evtString = compSerializer.SerializeToString();

            Assert.IsTrue(evtString.Equals("BEGIN:VEVENT\r\nCREATED:20070319T000000Z\r\nDTEND:20070320T000000Z\r\nDTSTAMP:20070319T000000Z\r\nDTSTART;VALUE=DATE:20070319\r\nDURATION:P1D\r\nRRULE:FREQ=WEEKLY;INTERVAL=3;COUNT=4;BYDAY=TU,FR,SU\r\nSUMMARY:Test event title\r\nUID:123456789\r\nEND:VEVENT\r\n"), "ComponentBaseSerializer.SerializeToString() serialized incorrectly");
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:27,代码来源:Serialize.cs

示例3: Event5

        public void Event5()
        {
            iCalendar iCal = new iCalendar();

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event title";
            evt.Start = new iCalDateTime(2007, 3, 19);
            evt.Start.IsUniversalTime = true;
            evt.Duration = new TimeSpan(24, 0, 0);
            evt.Created = evt.Start.Copy<IDateTime>();
            evt.DTStamp = evt.Start.Copy<IDateTime>();
            evt.UID = "123456789";
            evt.IsAllDay = true;

            RecurrencePattern rec = new RecurrencePattern("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4");
            evt.RecurrenceRules.Add(rec);

            iCalendarSerializer serializer = new iCalendarSerializer();
            string icalString = serializer.SerializeToString(iCal);

            Assert.IsFalse(String.Empty == icalString, "iCalendarSerializer.SerializeToString() must not be empty");

            EventSerializer eventSerializer = new EventSerializer();
            string evtString = eventSerializer.SerializeToString(evt);

            var target = "BEGIN:VEVENT\r\nCREATED:20070319T000000Z\r\nDTEND;VALUE=DATE:20070320\r\nDTSTAMP:20070319T000000Z\r\nDTSTART;VALUE=DATE:20070319\r\nRRULE:FREQ=WEEKLY;INTERVAL=3;COUNT=4;BYDAY=TU,FR,SU\r\nSEQUENCE:0\r\nSUMMARY:Test event title\r\nUID:123456789\r\nEND:VEVENT\r\n";
            Assert.AreEqual(target, evtString, "ComponentBaseSerializer.SerializeToString() serialized incorrectly");

            serializer.Serialize(iCal, @"Calendars/Serialization/Event5.ics");
            SerializeTest("Event5.ics", typeof(iCalendarSerializer));
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:31,代码来源:SerializationTest.cs

示例4: BugFromForumTopic3355446

        public void BugFromForumTopic3355446()
        {
            var ical = new iCalendar();
            var evt = ical.Create<Event>();
            
            var altDescProp = new CalendarProperty("X-ALT-DESC");
            altDescProp.AddParameter("FMTTYPE", "text/html");
            altDescProp.Value = "<a href=\"http://test.com\">some html</a>";
            evt.AddProperty(altDescProp);

            evt.Summary = "Test";
            evt.Description = "Test";
            evt.Start = new iCalDateTime(2012, 7, 30, 8, 0, 0);
            evt.Duration = TimeSpan.FromHours(1);

            var serializer = new iCalendarSerializer();
            var serializedString = serializer.SerializeToString(ical);

            Assert.IsTrue(serializedString.Contains("FMTTYPE=text/html"));
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:20,代码来源:SerializationTest.cs

示例5: Bug3512192

        public void Bug3512192()
        {
            IICalendar calendar = new iCalendar();
            calendar.Method = "PUBLISH";
            IEvent evt = calendar.Create<Event>();
            evt.Summary = "Test Event";
            evt.Start = new iCalDateTime(2012, 3, 27, 22, 00, 00);
            evt.Duration = TimeSpan.FromHours(1);

            var attendees = new List<IAttendee>();
            var attendee = new Attendee("MAILTO:[email protected]")
            {
                CommonName = "Test Name",
                Role = "OPT-PARTICIPANT",
                Members = new List<string>() { "Other", "Name" }
            };
            attendees.Add(attendee);
            
            evt.Attendees = attendees;

            // Serialize (save) the iCalendar 
            var serializer = new iCalendarSerializer(calendar);
            var result = serializer.SerializeToString(calendar);

            var calendars = serializer.Deserialize(new StringReader(result)) as IICalendarCollection;
            calendar = calendars.First();
            evt = calendar.Events.First();

            Assert.AreEqual(1, evt.Attendees.Count);
            Assert.AreEqual(attendee, evt.Attendees[0]);
            Assert.AreEqual("Test Name", evt.Attendees[0].CommonName);
            Assert.AreEqual("OPT-PARTICIPANT", evt.Attendees[0].Role);
            Assert.AreEqual(1, evt.Attendees[0].Members.Count);
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:34,代码来源:SerializationTest.cs

示例6: Bug3485766

        public void Bug3485766()
        {
            IICalendar calendar = new iCalendar();
            IEvent evt = calendar.Create<Event>();
            evt.Start = new iCalDateTime(2012, 5, 23, 8, 0, 0);
            evt.Duration = TimeSpan.FromMinutes(30);

            // Ensure the DTStamp is in universal time to begin with
            Assert.IsTrue(evt.DTStamp.IsUniversalTime);

            // Convert to local time
            evt.DTStamp = new iCalDateTime(evt.DTStamp.Local);

            // Serialize the calendar
            var serializer = new iCalendarSerializer();
            var serialized = serializer.SerializeToString(calendar);
            IICalendarCollection calendars = serializer.Deserialize(new StringReader(serialized)) as IICalendarCollection;
            calendar = calendars.First();
            evt = calendar.Events[0];

            // Ensure the object was serialized as UTC
            Assert.IsTrue(evt.DTStamp.IsUniversalTime);
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:23,代码来源:SerializationTest.cs

示例7: XProperty4

        public void XProperty4()
        {
            iCalendar iCal = new iCalendar();
            iCal.AddProperty("X-WR-CALNAME", "DDay Test");
            iCal.AddProperty("X-WR-CALDESC", "Events for a DDay Test");
            iCal.AddProperty("X-PUBLISHED-TTL", "PT30M");
            iCal.ProductID = "-//DDAYTEST//NONSGML www.test.com//EN";

            // Create an event in the iCalendar
            Event evt = iCal.Create<Event>();

            // Populate the properties
            evt.Start = new iCalDateTime(2009, 6, 28, 8, 0, 0);
            evt.Duration = TimeSpan.FromHours(1);
            evt.Url = new Uri("http://www.ftb.pl/news/59941_0_1/tunnel-electrocity-2008-timetable.htm");
            evt.Summary = "This is a title";
            evt.Description = "This is a description";

            iCalendarSerializer serializer = new iCalendarSerializer();
            string output = serializer.SerializeToString(iCal);
            serializer.Serialize(iCal, @"Calendars/Serialization/XProperty4.ics");

            Assert.IsFalse(Regex.IsMatch(output, @"\r\n[\r\n]"));

            SerializeTest("XProperty4.ics", typeof(iCalendarSerializer));
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:26,代码来源:SerializationTest.cs

示例8: TODO11

        public void TODO11()
        {
            iCalendar iCal = new iCalendar();
            Todo todo = iCal.Create<Todo>();

            todo.Summary = "xxxx";
            todo.Description = "fdsdsfds";

            // Set Start & Due date
            todo.DTStart = new DateTime(2007, 1, 1, 8, 0, 0);
            todo.Due = new DateTime(2007, 1, 7);
            todo.Created = DateTime.SpecifyKind(new DateTime(2007, 1, 1), DateTimeKind.Utc);
            todo.DTStamp = DateTime.SpecifyKind(new DateTime(2007, 1, 1), DateTimeKind.Utc);
            todo.UID = "b6709c95-5523-46aa-a7e5-1b5ea034b86a";

            // Add an alarm in my task 
            Alarm al = new Alarm(todo);
            al.Action = AlarmAction.Display;
            al.Description = "Reminder";
            al.Trigger = new Trigger();

            // Set reminder time 
            al.Trigger.DateTime = new DateTime(2007, 1, 6, 8, 0, 0);

            // Save into calendar file.
            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            string serializedTodo = serializer.SerializeToString();

            Assert.AreEqual(
                "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//DDay.iCal//NONSGML ddaysoftware.com//EN\r\nBEGIN:VTODO\r\nCREATED:20070101T000000Z\r\nDESCRIPTION:fdsdsfds\r\nDTSTAMP:20070101T000000Z\r\nDTSTART:20070101T080000\r\nDUE;VALUE=DATE:20070107\r\nDURATION:P5DT16H\r\nSEQUENCE:0\r\nSTATUS:NEEDS-ACTION\r\nSUMMARY:xxxx\r\nUID:b6709c95-5523-46aa-a7e5-1b5ea034b86a\r\nBEGIN:VALARM\r\nACTION:DISPLAY\r\nDESCRIPTION:Reminder\r\nTRIGGER;VALUE=DATE-TIME:20070106T080000\r\nEND:VALARM\r\nEND:VTODO\r\nEND:VCALENDAR\r\n",
                serializedTodo);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:32,代码来源:TodoTest.cs

示例9: TODO10

        public void TODO10()
        {
            iCalendar iCal = new iCalendar();
            Todo todo = iCal.Create<Todo>();

            todo.Summary = "xxxx";
            todo.Description = "fdsdsfds";

            // Set Start & Due date
            todo.DTStart = new DateTime(2007, 1, 1, 8, 0, 0);
            todo.Due = new DateTime(2007, 1, 7);
            todo.Created = DateTime.SpecifyKind(new DateTime(2007, 1, 1), DateTimeKind.Utc);
            todo.DTStamp = DateTime.SpecifyKind(new DateTime(2007, 1, 1), DateTimeKind.Utc);
            todo.UID = "b6709c95-5523-46aa-a7e5-1b5ea034b86a";

            // Create an alarm
            Alarm al = new Alarm();
            al.Trigger = new Trigger(TimeSpan.FromMinutes(-30));
            al.Action = AlarmAction.Display;
            al.Description = "Reminder";

            // Add the alarm to the todo item
            todo.AddAlarm(al);

            // Save into calendar file.
            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            string serializedTodo = serializer.SerializeToString();

            Assert.AreEqual(
                "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//DDay.iCal//NONSGML ddaysoftware.com//EN\r\nBEGIN:VTODO\r\nCREATED:20070101T000000Z\r\nDESCRIPTION:fdsdsfds\r\nDTSTAMP:20070101T000000Z\r\nDTSTART:20070101T080000\r\nDUE;VALUE=DATE:20070107\r\nDURATION:P5DT16H\r\nSEQUENCE:0\r\nSTATUS:NEEDS-ACTION\r\nSUMMARY:xxxx\r\nUID:b6709c95-5523-46aa-a7e5-1b5ea034b86a\r\nBEGIN:VALARM\r\nACTION:DISPLAY\r\nDESCRIPTION:Reminder\r\nTRIGGER:-PT30M\r\nEND:VALARM\r\nEND:VTODO\r\nEND:VCALENDAR\r\n",
                serializedTodo);

            List<AlarmOccurrence> alarms = todo.PollAlarms(
                new DateTime(2007, 1, 1),
                new DateTime(2007, 2, 1));
                        
            iCalDateTime expectedAlarm = new iCalDateTime(2007, 1, 1, 7, 30, 0);
            Assert.AreEqual(1, alarms.Count, "There should be exactly 1 alarm");
            Assert.AreEqual(expectedAlarm, alarms[0].DateTime, "The alarm should occur at " + expectedAlarm);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:40,代码来源:TodoTest.cs

示例10: CreateCalendarEvent

        /// <summary>
        /// This method is used when Start and End time both are supplied
        /// </summary>
        /// <param name="title"></param>
        /// <param name="body"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="location"></param>
        /// <param name="organizer"></param>
        /// <param name="eventId"></param>
        /// <param name="allDayEvent"></param>
        /// <returns></returns>
        private static string CreateCalendarEvent(string title, string body, DateTime startDate, DateTime endDate, string location, string organizer, string eventId, bool allDayEvent)
        {
            var iCal = new iCalendar
            {
                Method = "PUBLISH", //PUBLISH
                Version = "2.0"
            };
            // Create the event
            var evt = iCal.Create<Event>();
            //Subject
            evt.Summary = title;
            //Start Time
            evt.Start = new iCalDateTime(startDate.Year,
                                         startDate.Month, startDate.Day, startDate.Hour,
                                         startDate.Minute, startDate.Second);
            //End Time
            evt.End = new iCalDateTime(endDate.Year,
                                         endDate.Month, endDate.Day, endDate.Hour,
                                         endDate.Minute, endDate.Second);
            //Description of the Event
            evt.Description = body;
            //Location for the Event
            evt.Location = location;
            //Is All Day flag
            evt.IsAllDay = allDayEvent;
            //Event Id
            evt.UID = new Guid().ToString();

            //organizer is mandatory for outlook 2007 - think about
            // throwing an exception here.
            if (!String.IsNullOrEmpty(organizer))
            {
                evt.Organizer = new Organizer(organizer);
            }
            else
            {
                throw new Exception("Organizer provided was null");
            }

            if (!String.IsNullOrEmpty(eventId))
            {
                evt.UID = eventId;
            }

            var alarm = new Alarm
            {
                Duration = new TimeSpan(0, 15, 0),
                Trigger = new Trigger(new TimeSpan(0, 15, 0)),
                Action = AlarmAction.Display,
                Description = "Reminder"
            };

            evt.Alarms.Add(alarm);

            // Save into calendar file.
            var serializer = new iCalendarSerializer(iCal);

            return serializer.SerializeToString(iCal);
        }
开发者ID:jigshGitHub,项目名称:SandlerTrainingDevelopment,代码行数:71,代码来源:EmailController.cs

示例11: SERIALIZE18

        public void SERIALIZE18()
        {
            iCalendar iCal = new iCalendar();

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event title";
            evt.Start = DateTime.Today;
            evt.End = DateTime.Today.AddDays(1);
            evt.IsAllDay = true;            

            Recur rec = new Recur("FREQ=WEEKLY;INTERVAL=3;BYDAY=TU,FR,SU;COUNT=4");
            evt.AddRecurrence(rec);

            iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            string icalString = serializer.SerializeToString();

            Assert.IsNotEmpty(icalString, "iCalendarSerializer.SerializeToString() must not be empty");

            ComponentBaseSerializer compSerializer = new ComponentBaseSerializer(evt);
            string evtString = compSerializer.SerializeToString();

            Assert.IsTrue(evtString.Equals("BEGIN:VEVENT\r\nDTEND:20070320T060000Z\r\nDTSTART;VALUE=DATE:20070319\r\nDURATION:P1D\r\nRRULE:FREQ=WEEKLY;INTERVAL=3;COUNT=4;BYDAY=TU,FR,SU\r\nSUMMARY:Test event title\r\nEND:VEVENT\r\n"), "ComponentBaseSerializer.SerializeToString() serialized incorrectly");
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:23,代码来源:Serialize.cs


注:本文中的DDay.iCal.Serialization.iCalendarSerializer.SerializeToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。