5

誰かが助けてくれることを願っています。DDay.iCalバージョン1.0.1.490と.netバージョン2を使用すると、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);
      }
   }
}
4

1 に答える 1

10

この行Event evt = iCal.Create<Event>()は、新しいイベントを作成し、それをカレンダーのイベントコレクションに追加して、それを返します。後で、同じイベントをカレンダーのイベントコレクションに手動で追加します。iCal.Events.Add(evt)

私は同じことをしていましたが、Create()メソッドがカレンダーにイベントを追加することに気づいていませんでした。標準のコンストラクターを使用してイベントを初期化するか、カレンダーのイベントコレクションのEvent evt = new Event()マニュアルを削除します。Add()

于 2011-08-22T14:36:04.407 に答える