private void AssignProperties(Appointment apt, Event instance)
        {
            instance.Summary     = apt.Subject;
            instance.Description = apt.Description;
            instance.Location    = apt.Location;

            instance.Start = GoogleCalendarUtils.ConvertEventDateTime(apt.Start);
            instance.End   = GoogleCalendarUtils.ConvertEventDateTime(apt.End);
        }
        void ExportAppointment(Appointment apt)
        {
            AppointmentType aptType = apt.Type;

            if (aptType == AppointmentType.Pattern)
            {
                EnsurePatternId(apt);
            }
            else if (aptType != AppointmentType.Normal)
            {
                string eventPatternId = EnsurePatternId(apt.RecurrencePattern);
                Debug.Assert(!String.IsNullOrEmpty(eventPatternId));
                if (aptType == AppointmentType.Occurrence)
                {
                    return;
                }
                EventsResource.InstancesRequest instancesRequest = CalendarService.Events.Instances(CalendarEntry.Id, eventPatternId);
                OccurrenceCalculator            calculator       = OccurrenceCalculator.CreateInstance(apt.RecurrencePattern.RecurrenceInfo);
                instancesRequest.OriginalStart = GoogleCalendarUtils.ConvertEventDateTime(calculator.CalcOccurrenceStartTime(apt.RecurrenceIndex)).DateTimeRaw;
                Events occurrenceEvents = instancesRequest.Execute();
                Debug.Assert(occurrenceEvents.Items.Count == 1);
                Event occurrence = occurrenceEvents.Items[0];
                if (aptType == AppointmentType.ChangedOccurrence)
                {
                    this.AssignProperties(apt, occurrence);
                }
                else if (aptType == AppointmentType.DeletedOccurrence)
                {
                    occurrence.Status = "cancelled";
                }
                Event changedOccurrence = CalendarService.Events.Update(occurrence, CalendarEntry.Id, occurrence.Id).Execute();
                apt.CustomFields["eventId"] = changedOccurrence.Id;
                Log.WriteLine(String.Format("Exported {0} occurrance: {1}, id={2}", (aptType == AppointmentType.ChangedOccurrence) ? "changed" : "deleted", apt.Subject, changedOccurrence.Id));
                return;
            }

            Event instance = this.CreateEvent(aptType);

            AssignProperties(apt, instance);

            Event result = CalendarService.Events.Insert(instance, CalendarEntry.Id).Execute();

            Log.WriteLine(String.Format("Exported appointment: {0}, id={1}", apt.Subject, result.Id));
        }