希望有人能帮上忙。在.net版本2中使用DDay.iCal版本1.0.1.490时,我在调用SerilizeToString方法后得到重复的事件事件。
示例代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DDay.iCal;
using DDay.iCal.Serialization.iCalendar;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
iCalendar iCal = new iCalendar();
Event evt = iCal.Create<Event>();
Uri eventLink = new Uri("http://middlebury.edu";);
evt.IsAllDay = false;
evt.Start = new iCalDateTime(DateTime.Parse("2011-08-11"));
evt.Duration = new TimeSpan(2, 0, 0);
evt.Location = "Test";
evt.Summary = "Breakfast";
evt.Url = eventLink;
evt.Description = "Sausage Links" + "\n" + "Pancakes" + "\n";
iCal.Events.Add(evt);
iCalendarSerializer serializer = new iCalendarSerializer(iCal);
string result = serializer.SerializeToString(iCal);
}
}
}发布于 2011-08-22 22:36:04
行Event evt = iCal.Create<Event>()创建一个新事件,将其添加到日历的事件集合中,然后返回它。稍后,您可以手动将相同的事件添加到日历的事件集合中:iCal.Events.Add(evt)
我也在做同样的事情,没有意识到Create()方法会将事件添加到日历中。可以使用标准构造函数Event evt = new Event()初始化事件,也可以删除日历事件集合的手动Add()。
https://stackoverflow.com/questions/7110743
复制相似问题