示例#1
0
        private static List <ITranslationRule <ICalendarItemBase, Event> > CreateTranslationRules()
        {
            ITranslationRule <ICalendarItemBase, IActionPropagationState>  lastExecutedInteropActionRule = CalendarItemAccessors.LastExecutedInteropAction.MapTo(Event.Accessors.LastExecutedInteropAction);
            TranslationStrategy <ICalendarItem, PropertyDefinition, Event> internalRule = new TranslationStrategy <ICalendarItem, PropertyDefinition, Event>(new ITranslationRule <ICalendarItem, Event>[]
            {
                new PatternedRecurrenceRule(),
                CalendarItemAccessors.SeriesMasterDataPropagationOperation.MapTo(Event.Accessors.InternalSeriesToInstancePropagation),
                CalendarItemAccessors.MarkAllPropagatedPropertiesAsException.MapTo(Event.Accessors.InternalMarkAllPropagatedPropertiesAsException)
            });
            TranslationStrategy <ICalendarItemSeries, PropertyDefinition, Event> internalRule2 = new TranslationStrategy <ICalendarItemSeries, PropertyDefinition, Event>(new ITranslationRule <ICalendarItemSeries, Event>[]
            {
                CalendarItemAccessors.SeriesCreationHash.MapTo(Event.Accessors.InternalSeriesCreationHash),
                CalendarItemAccessors.SeriesSequenceNumber.MapTo(Event.Accessors.InternalSeriesSequenceNumber),
                new ActionQueueRules()
            });
            DateTimeHelper    dateTimeHelper = new DateTimeHelper();
            FreeBusyConverter converter      = default(FreeBusyConverter);

            return(new List <ITranslationRule <ICalendarItemBase, Event> >
            {
                new DraftStateRules(),
                CalendarItemAccessors.Attendees.MapTo(Event.Accessors.Attendees),
                CalendarItemAccessors.DisallowNewTimeProposal.MapTo(Event.Accessors.DisallowNewTimeProposal),
                CalendarItemAccessors.EndTime.MapTo(CalendarItemAccessors.EndTimeZone, Event.Accessors.End, Event.Accessors.IntendedEndTimeZoneId, dateTimeHelper),
                CalendarItemAccessors.GlobalObjectId.MapTo(Event.Accessors.InternalGlobalObjectId, default(GlobalObjectIdConverter)),
                CalendarItemAccessors.HasAttendees.MapTo(Event.Accessors.HasAttendees),
                CalendarItemAccessors.IntendedFreeBusyStatus.MapTo(Event.Accessors.IntendedStatus, converter),
                CalendarItemAccessors.IsAllDay.MapTo(Event.Accessors.IsAllDay),
                CalendarItemAccessors.IsCancelled.MapTo(Event.Accessors.IsCancelled),
                CalendarItemAccessors.IsOnlineMeeting.MapTo(Event.Accessors.IsOnlineMeeting),
                CalendarItemAccessors.IsOrganizer.MapTo(Event.Accessors.IsOrganizer),
                CalendarItemAccessors.Location.MapTo(Event.Accessors.Location),
                CalendarItemAccessors.OnlineMeetingConfLink.MapTo(Event.Accessors.OnlineMeetingConfLink),
                CalendarItemAccessors.OnlineMeetingExternalLink.MapTo(Event.Accessors.OnlineMeetingExternalLink),
                CalendarItemAccessors.Organizer.MapTo(Event.Accessors.Organizer),
                CalendarItemAccessors.ResponseRequested.MapTo(Event.Accessors.ResponseRequested),
                new ResponseStatusRule(),
                EventTranslator.SeriesIdRule,
                CalendarItemAccessors.FreeBusyStatus.MapTo(Event.Accessors.ShowAs, converter),
                CalendarItemAccessors.StartTime.MapTo(CalendarItemAccessors.StartTimeZone, Event.Accessors.Start, Event.Accessors.IntendedStartTimeZoneId, dateTimeHelper),
                EventTranslator.EventTypeTranslationRule,
                CalendarItemAccessors.IsReceivedAccessor.MapTo(Event.Accessors.InternalIsReceived),
                new DelegatedTranslationRule <ICalendarItemBase, Event>(delegate(ICalendarItemBase calendarItemBase, Event theEvent)
                {
                    if (!(calendarItemBase is ICalendarItemOccurrence))
                    {
                        lastExecutedInteropActionRule.FromLeftToRightType(calendarItemBase, theEvent);
                    }
                }, new Action <ICalendarItemBase, Event>(lastExecutedInteropActionRule.FromRightToLeftType)),
                internalRule.OfType <ICalendarItemBase, Event, ICalendarItem, Event>(),
                internalRule2.OfType <ICalendarItemBase, Event, ICalendarItemSeries, Event>(),
                new EventPopupReminderSettingsRules(),
                EventTranslator.SeriesMasterIdRule
            });
        }
示例#2
0
        private static List <ITranslationRule <IAttachment, IAttachment> > CreateTranslationRules(bool includeContentProperties)
        {
            TranslationStrategy <IAttachment, PropertyDefinition, Attachment <TSchema> > internalRule = new TranslationStrategy <IAttachment, PropertyDefinition, Attachment <TSchema> >(new ITranslationRule <IAttachment, Attachment <TSchema> > [0])
            {
                AttachmentAccessors.ContentType.MapTo(Attachment <TSchema> .Accessors.ContentType),
                AttachmentAccessors.Id.MapTo(Entity <TSchema> .Accessors.Id),
                AttachmentAccessors.IsInline.MapTo(Attachment <TSchema> .Accessors.IsInline),
                AttachmentAccessors.LastModifiedTime.MapTo(Attachment <TSchema> .Accessors.LastModifiedTime),
                AttachmentAccessors.Name.MapTo(Attachment <TSchema> .Accessors.Name),
                AttachmentAccessors.Size.MapTo(Attachment <TSchema> .Accessors.Size)
            };
            TranslationStrategy <IStreamAttachment, PropertyDefinition, FileAttachment> translationStrategy = new TranslationStrategy <IStreamAttachment, PropertyDefinition, FileAttachment>(new ITranslationRule <IStreamAttachment, FileAttachment> [0])
            {
                AttachmentAccessors.ContentId.MapTo(FileAttachment.Accessors.ContentId),
                AttachmentAccessors.ContentLocation.MapTo(FileAttachment.Accessors.ContentLocation)
            };

            if (includeContentProperties)
            {
                translationStrategy.Add(AttachmentAccessors.Content.MapTo(FileAttachment.Accessors.Content));
            }
            TranslationStrategy <IReferenceAttachment, PropertyDefinition, ReferenceAttachment> internalRule2 = new TranslationStrategy <IReferenceAttachment, PropertyDefinition, ReferenceAttachment>(new ITranslationRule <IReferenceAttachment, ReferenceAttachment> [0])
            {
                AttachmentAccessors.PathName.MapTo(ReferenceAttachment.Accessors.PathName),
                AttachmentAccessors.ProviderEndpointUrl.MapTo(ReferenceAttachment.Accessors.ProviderEndpointUrl),
                AttachmentAccessors.ProviderType.MapTo(ReferenceAttachment.Accessors.ProviderType)
            };
            List <ITranslationRule <IAttachment, IAttachment> > list = new List <ITranslationRule <IAttachment, IAttachment> >
            {
                internalRule.OfType <IAttachment, IAttachment, IAttachment, Attachment <TSchema> >(),
                translationStrategy.OfType <IAttachment, IAttachment, IStreamAttachment, FileAttachment>(),
                internalRule2.OfType <IAttachment, IAttachment, IReferenceAttachment, ReferenceAttachment>()
            };

            if (includeContentProperties)
            {
                list.Add(new EmbededItemTranslationRule().OfType <IAttachment, IAttachment, ItemAttachment, ItemAttachment>());
            }
            return(list);
        }