Exemple #1
0
 public void Serialize(System.IO.TextWriter wrtr)
 {
     wrtr.BeginBlock(Type.ToUpper());
     wrtr.Property("TZID", ID);
     wrtr.Property("TZNAME", Name);
     wrtr.Property("DTSTART", Start);
     if (Recurrences != null)
     {
         foreach (var rule in Recurrences)
         {
             wrtr.Property("RRULE", rule);
         }
     }
     if (OffsetFrom != null)
     {
         wrtr.Property("TZOFFSETFROM", OffsetFrom.Value.FormatOffset());
     }
     if (OffsetFrom != null)
     {
         wrtr.Property("TZOFFSETTO", OffsetTo.Value.FormatOffset());
     }
     wrtr.EndBlock(Type.ToUpper());
 }
Exemple #2
0
        public void Serialize(System.IO.TextWriter wrtr)
        {
            if (End != null && Start != null && End < Start)
            {
                End = Start;
            }


            wrtr.BeginBlock("VEVENT");
            wrtr.Property("UID", UID);
            if (Attendees != null)
            {
                foreach (var attendee in Attendees)
                {
                    wrtr.Property("ATTENDEE", attendee);
                }
            }
            if (Categories != null && Categories.Count > 0)
            {
                wrtr.Property("CATEGORIES", Categories);
            }
            wrtr.Property("CLASS", Class);
            wrtr.Property("CREATED", Created);
            wrtr.Property("DESCRIPTION", Description);
            NameValueCollection startParameter = new NameValueCollection();
            NameValueCollection endParameter   = new NameValueCollection();

            if (!String.IsNullOrEmpty(StartTzid))
            {
                startParameter.Add("TZID", StartTzid);
            }
            if (!String.IsNullOrEmpty(EndTzid))
            {
                endParameter.Add("TZID", EndTzid);
            }

            if (!IsAllDayEvent)
            {
                wrtr.Property("DTSTART", Start, parameters: startParameter);
                wrtr.Property("DTEND", End, parameters: endParameter);
            }
            else
            {
                wrtr.Property("DTSTART", Start.Value.ToString("yyyyMMdd"), parameters: startParameter);
                wrtr.Property("DTEND", End.Value.ToString("yyyyMMdd"), parameters: endParameter);
            }

            wrtr.Property("DTSTAMP", DTSTAMP);
            wrtr.Property("LAST-MODIFIED", LastModified);
            wrtr.Property("LOCATION", Location);
            wrtr.Property("ORGANIZER", Organizer);
            wrtr.Property("PRIORITY", Priority);
            wrtr.Property("SEQUENCE", Sequence);
            wrtr.Property("STATUS", Status);
            wrtr.Property("SUMMARY", Summary);
            if (Recurrences.Any())
            {
                foreach (var recurrence in Recurrences)
                {
                    wrtr.Property("RRULE", recurrence.ToString(), encoded: true);
                }
            }

            if (ExDates.Any())
            {
                if (!IsAllDayEvent)
                {
                    foreach (var exdate in ExDates)
                    {
                        wrtr.Property("EXDATE", exdate);
                    }
                }
                else
                {
                    foreach (var exdate in ExDates)
                    {
                        //allday
                        NameValueCollection extDateParam = new NameValueCollection();
                        extDateParam.Add("VALUE", "DATE");
                        wrtr.Property("EXDATE", exdate.ToString("yyyyMMdd"), parameters: extDateParam);
                    }
                }
            }

            wrtr.Property("TRANSP", Transparency);
            wrtr.Property("URL", Url);
            if (Properties != null)
            {
                foreach (var prop in Properties)
                {
                    wrtr.Property(prop.Item1, prop.Item2, parameters: prop.Item3);
                }
            }

            if (Alarms != null)
            {
                foreach (var alarm in Alarms)
                {
                    alarm.Serialize(wrtr);
                }
            }
            wrtr.EndBlock("VEVENT");
        }