private IOutlookSynchronizer CreateGoogleContactSynchronizer(Options options, AvailableSynchronizerComponents componentsToFill)
        {
            var atypeRepository = new OutlookContactRepository <GoogleContactContext> (
                _outlookSession,
                options.OutlookFolderEntryId,
                options.OutlookFolderStoreId,
                _daslFilterProvider);

            IWebProxy proxy = options.ProxyOptions != null?CreateProxy(options.ProxyOptions) : null;

            var googleApiExecutor = new GoogleApiOperationExecutor(
                System.Threading.Tasks.Task.Run(() => OAuth.Google.GoogleHttpClientFactory.LoginToContactsService(options.UserName, proxy).Result).Result);

            var mappingParameters = GetMappingParameters <ContactMappingConfiguration> (options);

            var atypeIdEqulityComparer  = EqualityComparer <string> .Default;
            var btypeIdEqualityComparer = EqualityComparer <string> .Default;

            var btypeRepository = new GoogleContactRepository(googleApiExecutor, options.UserName, mappingParameters, btypeIdEqualityComparer);

            var entityMapper = new GoogleContactEntityMapper(mappingParameters);

            var entityRelationDataFactory = new GoogleContactRelationDataFactory();

            var syncStateFactory = new EntitySyncStateFactory <string, DateTime, ContactItemWrapper, string, GoogleContactVersion, GoogleContactWrapper> (
                entityMapper,
                entityRelationDataFactory,
                ExceptionHandler.Instance);

            var storageDataDirectory = _profileDataDirectoryFactory(options.Id);

            var storageDataAccess = new EntityRelationDataAccess <string, DateTime, GoogleContactRelationData, string, GoogleContactVersion> (storageDataDirectory);

            var atypeWriteRepository = BatchEntityRepositoryAdapter.Create <ContactItemWrapper, string, DateTime, GoogleContactContext> (atypeRepository);

            var synchronizer = new Synchronizer <string, DateTime, ContactItemWrapper, string, GoogleContactVersion, GoogleContactWrapper, GoogleContactContext> (
                atypeRepository,
                btypeRepository,
                atypeWriteRepository,
                btypeRepository,
                InitialSyncStateCreationStrategyFactory <string, DateTime, ContactItemWrapper, string, GoogleContactVersion, GoogleContactWrapper> .Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution,
                    e => new GoogleContactConflictInitialSyncStateCreationStrategyAutomatic(e)),
                storageDataAccess,
                entityRelationDataFactory,
                new InitialGoogleContactEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqulityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                ExceptionHandler.Instance,
                new GoogleContactContextFactory(googleApiExecutor, btypeIdEqualityComparer, options.UserName),
                EqualityComparer <DateTime> .Default,
                new GoogleContactVersionComparer());

            return(new OutlookSynchronizer <string, GoogleContactVersion> (synchronizer));
        }
Exemple #2
0
        private ISynchronizer <DistributionListSychronizationContext> CreateDistListSynchronizer(
            Options options,
            GeneralOptions generalOptions,
            CardDavEntityRepository <DistributionList, int, DistributionListSychronizationContext> btypeRepository)
        {
            var atypeRepository = new OutlookDistListRepository <DistributionListSychronizationContext> (
                _outlookSession,
                options.OutlookFolderEntryId,
                options.OutlookFolderStoreId,
                _daslFilterProvider,
                _queryFolderStrategy);

            var entityMapper = new DistListEntityMapper();

            var entityRelationDataFactory = new DistListRelationDataFactory();

            var syncStateFactory = new EntitySyncStateFactory <string, DateTime, GenericComObjectWrapper <DistListItem>, WebResourceName, string, DistributionList, DistributionListSychronizationContext> (
                entityMapper,
                entityRelationDataFactory,
                ExceptionHandler.Instance);

            var btypeIdEqualityComparer = WebResourceName.Comparer;
            var atypeIdEqulityComparer  = EqualityComparer <string> .Default;

            var storageDataDirectory = _profileDataDirectoryFactory(options.Id);

            var storageDataAccess = new EntityRelationDataAccess <string, DateTime, DistListRelationData, WebResourceName, string> (storageDataDirectory, "distList");

            var atypeWriteRepository = BatchEntityRepositoryAdapter.Create(atypeRepository);
            var btypeWriteRepository = BatchEntityRepositoryAdapter.Create(btypeRepository);

            var synchronizer = new Synchronizer <string, DateTime, GenericComObjectWrapper <DistListItem>, WebResourceName, string, DistributionList, DistributionListSychronizationContext> (
                atypeRepository,
                btypeRepository,
                atypeWriteRepository,
                btypeWriteRepository,
                InitialSyncStateCreationStrategyFactory <string, DateTime, GenericComObjectWrapper <DistListItem>, WebResourceName, string, DistributionList, DistributionListSychronizationContext> .Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution,
                    e => new DistListConflictInitialSyncStateCreationStrategyAutomatic(e)),
                storageDataAccess,
                entityRelationDataFactory,
                new InitialDistListEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqulityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                EqualityComparer <DateTime> .Default,
                EqualityComparer <string> .Default,
                syncStateFactory);

            return(synchronizer);
        }
        private IOutlookSynchronizer CreateContactSynchronizer(Options options, GeneralOptions generalOptions, AvailableSynchronizerComponents componentsToFill)
        {
            var atypeRepository = new OutlookContactRepository <int> (
                _outlookSession,
                options.OutlookFolderEntryId,
                options.OutlookFolderStoreId,
                _daslFilterProvider);

            var cardDavDataAccess = new CardDavDataAccess(
                new Uri(options.CalenderUrl),
                CreateWebDavClient(
                    options.UserName,
                    options.GetEffectivePassword(_outlookAccountPasswordProvider),
                    options.CalenderUrl,
                    _calDavConnectTimeout,
                    options.ServerAdapterType,
                    options.CloseAfterEachRequest,
                    options.PreemptiveAuthentication,
                    options.ForceBasicAuthentication,
                    options.ProxyOptions,
                    generalOptions.AcceptInvalidCharsInServerResponse));

            componentsToFill.CardDavDataAccess = cardDavDataAccess;

            IEntityRepository <vCard, WebResourceName, string, int> btypeRepository = new CardDavRepository(
                cardDavDataAccess);

            var mappingParameters = GetMappingParameters <ContactMappingConfiguration> (options);

            var entityMapper = new ContactEntityMapper(mappingParameters);

            var entityRelationDataFactory = new OutlookContactRelationDataFactory();

            var syncStateFactory = new EntitySyncStateFactory <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard> (
                entityMapper,
                entityRelationDataFactory,
                ExceptionHandler.Instance);

            var btypeIdEqualityComparer = WebResourceName.Comparer;
            var atypeIdEqulityComparer  = EqualityComparer <string> .Default;

            var storageDataDirectory = _profileDataDirectoryFactory(options.Id);

            var storageDataAccess = new EntityRelationDataAccess <string, DateTime, OutlookContactRelationData, WebResourceName, string> (storageDataDirectory);

            var atypeWriteRepository = BatchEntityRepositoryAdapter.Create(atypeRepository);
            var btypeWriteRepository = BatchEntityRepositoryAdapter.Create(btypeRepository);

            var synchronizer = new Synchronizer <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard, int> (
                atypeRepository,
                btypeRepository,
                atypeWriteRepository,
                btypeWriteRepository,
                InitialSyncStateCreationStrategyFactory <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard> .Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution,
                    e => new ContactConflictInitialSyncStateCreationStrategyAutomatic(e)),
                storageDataAccess,
                entityRelationDataFactory,
                new InitialContactEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqulityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                ExceptionHandler.Instance,
                NullSynchronizationContextFactory.Instance,
                EqualityComparer <DateTime> .Default,
                EqualityComparer <string> .Default);

            return(new OutlookSynchronizer <WebResourceName, string> (synchronizer));
        }
        private IOutlookSynchronizer CreateGoogleTaskSynchronizer(Options options)
        {
            var atypeRepository = new OutlookTaskRepository(_outlookSession, options.OutlookFolderEntryId, options.OutlookFolderStoreId, _daslFilterProvider);

            IWebProxy proxy = options.ProxyOptions != null?CreateProxy(options.ProxyOptions) : null;

            var tasksService = System.Threading.Tasks.Task.Run(() => OAuth.Google.GoogleHttpClientFactory.LoginToGoogleTasksService(options.UserName, proxy).Result).Result;

            TaskList taskList;

            try
            {
                taskList = tasksService.Tasklists.Get(options.CalenderUrl).Execute();
            }
            catch (Google.GoogleApiException)
            {
                s_logger.ErrorFormat($"Profile '{options.Name}' (Id: '{options.Id}'): task list '{options.CalenderUrl}' not found.");
                throw;
            }

            var btypeRepository = new GoogleTaskRepository(tasksService, taskList);


            var relationDataFactory = new GoogleTaskRelationDataFactory();
            var syncStateFactory    = new EntitySyncStateFactory <string, DateTime, TaskItemWrapper, string, string, Task> (
                new GoogleTaskMapper(),
                relationDataFactory,
                ExceptionHandler.Instance);

            var storageDataDirectory = _profileDataDirectoryFactory(options.Id);

            var btypeIdEqualityComparer = EqualityComparer <string> .Default;
            var atypeIdEqualityComparer = EqualityComparer <string> .Default;

            var atypeWriteRepository = BatchEntityRepositoryAdapter.Create(atypeRepository);
            var btypeWriteRepository = BatchEntityRepositoryAdapter.Create(btypeRepository);

            var synchronizer = new Synchronizer <string, DateTime, TaskItemWrapper, string, string, Task, int> (
                atypeRepository,
                btypeRepository,
                atypeWriteRepository,
                btypeWriteRepository,
                InitialSyncStateCreationStrategyFactory <string, DateTime, TaskItemWrapper, string, string, Task> .Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution,
                    e => new GoogleTaskConflictInitialSyncStateCreationStrategyAutomatic(e)),
                new EntityRelationDataAccess <string, DateTime, GoogleTaskRelationData, string, string> (storageDataDirectory),
                relationDataFactory,
                new InitialGoogleTastEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqualityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                ExceptionHandler.Instance,
                NullSynchronizationContextFactory.Instance,
                EqualityComparer <DateTime> .Default,
                EqualityComparer <string> .Default);

            return(new OutlookSynchronizer <string, string> (synchronizer));
        }
        /// <remarks>
        /// Public because it is being used by integration tests
        /// </remarks>
        public IOutlookSynchronizer CreateEventSynchronizer(
            Options options,
            ICalDavDataAccess calDavDataAccess,
            IEntityRelationDataAccess <string, DateTime, WebResourceName, string> entityRelationDataAccess)
        {
            var dateTimeRangeProvider =
                options.IgnoreSynchronizationTimeRange ?
                NullDateTimeRangeProvider.Instance :
                new DateTimeRangeProvider(options.DaysToSynchronizeInThePast, options.DaysToSynchronizeInTheFuture);

            var mappingParameters = GetMappingParameters <EventMappingConfiguration> (options);

            var atypeRepository = new OutlookEventRepository(
                _outlookSession,
                options.OutlookFolderEntryId,
                options.OutlookFolderStoreId,
                dateTimeRangeProvider,
                mappingParameters,
                _daslFilterProvider);

            IEntityRepository <IICalendar, WebResourceName, string, int> btypeRepository = new CalDavRepository(
                calDavDataAccess,
                new iCalendarSerializer(),
                CalDavRepository.EntityType.Event,
                dateTimeRangeProvider,
                options.ServerAdapterType == ServerAdapterType.WebDavHttpClientBasedWithGoogleOAuth);

            var entityMapper = new EventEntityMapper(
                _outlookEmailAddress, new Uri("mailto:" + options.EmailAddress),
                _outlookSession.Application.TimeZones.CurrentTimeZone.ID,
                _outlookSession.Application.Version,
                mappingParameters);

            var outlookEventRelationDataFactory = new OutlookEventRelationDataFactory();

            var syncStateFactory = new EntitySyncStateFactory <string, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> (
                entityMapper,
                outlookEventRelationDataFactory,
                ExceptionHandler.Instance
                );

            var btypeIdEqualityComparer = WebResourceName.Comparer;
            var atypeIdEqualityComparer = EqualityComparer <string> .Default;

            var aTypeWriteRepository = BatchEntityRepositoryAdapter.Create(atypeRepository);
            var bTypeWriteRepository = BatchEntityRepositoryAdapter.Create(btypeRepository);

            var synchronizer = new Synchronizer <string, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar, int> (
                atypeRepository,
                btypeRepository,
                aTypeWriteRepository,
                bTypeWriteRepository,
                InitialSyncStateCreationStrategyFactory <string, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> .Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution,
                    e => new EventConflictInitialSyncStateCreationStrategyAutomatic(e)),
                entityRelationDataAccess,
                outlookEventRelationDataFactory,
                new InitialEventEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqualityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                ExceptionHandler.Instance,
                NullSynchronizationContextFactory.Instance,
                EqualityComparer <DateTime> .Default,
                EqualityComparer <string> .Default);

            return(new OutlookSynchronizer <WebResourceName, string> (synchronizer));
        }
        private IOutlookSynchronizer CreateTaskSynchronizer(Options options, GeneralOptions generalOptions, AvailableSynchronizerComponents componentsToFill)
        {
            var mappingParameters = GetMappingParameters <TaskMappingConfiguration> (options);

            var atypeRepository = new OutlookTaskRepository(_outlookSession, options.OutlookFolderEntryId, options.OutlookFolderStoreId, _daslFilterProvider, mappingParameters);



            ICalDavDataAccess calDavDataAccess;
            var calendarUrl = new Uri(options.CalenderUrl);

            if (calendarUrl.Scheme == Uri.UriSchemeFile)
            {
                calDavDataAccess = new FileSystemDavDataAccess(calendarUrl);
            }
            else
            {
                calDavDataAccess = new CalDavDataAccess(
                    calendarUrl,
                    CreateWebDavClient(
                        options.UserName,
                        options.GetEffectivePassword(_outlookAccountPasswordProvider),
                        options.CalenderUrl,
                        generalOptions.CalDavConnectTimeout,
                        options.ServerAdapterType,
                        options.CloseAfterEachRequest,
                        options.PreemptiveAuthentication,
                        options.ForceBasicAuthentication,
                        options.ProxyOptions,
                        generalOptions.EnableClientCertificate,
                        generalOptions.AcceptInvalidCharsInServerResponse));
            }

            componentsToFill.CalDavDataAccess = calDavDataAccess;

            var btypeRepository = new CalDavRepository <int> (
                calDavDataAccess,
                new iCalendarSerializer(),
                CalDavRepository.EntityType.Todo,
                NullDateTimeRangeProvider.Instance,
                false,
                options.IsChunkedSynchronizationEnabled ? new ChunkedExecutor(options.ChunkSize) : NullChunkedExecutor.Instance);

            var relationDataFactory = new TaskRelationDataFactory();
            var syncStateFactory    = new EntitySyncStateFactory <string, DateTime, TaskItemWrapper, WebResourceName, string, IICalendar> (
                new TaskMapper(_outlookSession.Application.TimeZones.CurrentTimeZone.ID, mappingParameters),
                relationDataFactory,
                ExceptionHandler.Instance);

            var storageDataDirectory = _profileDataDirectoryFactory(options.Id);

            var btypeIdEqualityComparer = WebResourceName.Comparer;
            var atypeIdEqualityComparer = EqualityComparer <string> .Default;

            var atypeWriteRepository = BatchEntityRepositoryAdapter.Create(atypeRepository);
            var btypeWriteRepository = BatchEntityRepositoryAdapter.Create(btypeRepository);

            var synchronizer = new Synchronizer <string, DateTime, TaskItemWrapper, WebResourceName, string, IICalendar, int> (
                atypeRepository,
                btypeRepository,
                atypeWriteRepository,
                btypeWriteRepository,
                InitialSyncStateCreationStrategyFactory <string, DateTime, TaskItemWrapper, WebResourceName, string, IICalendar> .Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution,
                    e => new TaskConflictInitialSyncStateCreationStrategyAutomatic(e)),
                new EntityRelationDataAccess <string, DateTime, TaskRelationData, WebResourceName, string> (storageDataDirectory),
                relationDataFactory,
                new InitialTaskEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqualityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                ExceptionHandler.Instance,
                NullSynchronizationContextFactory.Instance,
                EqualityComparer <DateTime> .Default,
                EqualityComparer <string> .Default,
                syncStateFactory);

            return(new OutlookSynchronizer <WebResourceName, string> (synchronizer));
        }
        /// <remarks>
        /// Public because it is being used by integration tests
        /// </remarks>
        public async Task <IOutlookSynchronizer> CreateEventSynchronizer(
            Options options,
            ICalDavDataAccess calDavDataAccess,
            IEntityRelationDataAccess <AppointmentId, DateTime, WebResourceName, string> entityRelationDataAccess)
        {
            var dateTimeRangeProvider =
                options.IgnoreSynchronizationTimeRange ?
                NullDateTimeRangeProvider.Instance :
                new DateTimeRangeProvider(options.DaysToSynchronizeInThePast, options.DaysToSynchronizeInTheFuture);

            var mappingParameters = GetMappingParameters <EventMappingConfiguration> (options);

            var atypeRepository = new OutlookEventRepository(
                _outlookSession,
                options.OutlookFolderEntryId,
                options.OutlookFolderStoreId,
                dateTimeRangeProvider,
                mappingParameters,
                _daslFilterProvider);

            IEntityRepository <WebResourceName, string, IICalendar, IEventSynchronizationContext> btypeRepository = new CalDavRepository <IEventSynchronizationContext> (
                calDavDataAccess,
                new iCalendarSerializer(),
                CalDavRepository.EntityType.Event,
                dateTimeRangeProvider,
                options.ServerAdapterType == ServerAdapterType.WebDavHttpClientBasedWithGoogleOAuth,
                options.IsChunkedSynchronizationEnabled ? new ChunkedExecutor(options.ChunkSize) : NullChunkedExecutor.Instance);

            var timeZoneCache = new TimeZoneCache(CreateHttpClient(options.ProxyOptions), mappingParameters.IncludeHistoricalData, _globalTimeZoneCache);

            ITimeZone configuredEventTimeZoneOrNull;

            if (mappingParameters.UseIanaTz)
            {
                configuredEventTimeZoneOrNull = await timeZoneCache.GetByTzIdOrNull(mappingParameters.EventTz);
            }
            else
            {
                configuredEventTimeZoneOrNull = null;
            }

            var entityMapper = new EventEntityMapper(
                _outlookEmailAddress, new Uri("mailto:" + options.EmailAddress),
                _outlookSession.Application.TimeZones.CurrentTimeZone.ID,
                _outlookSession.Application.Version,
                timeZoneCache,
                mappingParameters,
                configuredEventTimeZoneOrNull);

            var outlookEventRelationDataFactory = new OutlookEventRelationDataFactory();

            var syncStateFactory = new EntitySyncStateFactory <AppointmentId, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> (
                entityMapper,
                outlookEventRelationDataFactory,
                ExceptionHandler.Instance
                );

            var btypeIdEqualityComparer = WebResourceName.Comparer;
            var atypeIdEqualityComparer = AppointmentId.Comparer;

            var aTypeWriteRepository = BatchEntityRepositoryAdapter.Create(atypeRepository);
            var bTypeWriteRepository = BatchEntityRepositoryAdapter.Create(btypeRepository);

            var synchronizer = new Synchronizer <AppointmentId, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar, IEventSynchronizationContext> (
                atypeRepository,
                btypeRepository,
                aTypeWriteRepository,
                bTypeWriteRepository,
                InitialSyncStateCreationStrategyFactory <AppointmentId, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> .Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution,
                    e => new EventConflictInitialSyncStateCreationStrategyAutomatic(e)),
                entityRelationDataAccess,
                outlookEventRelationDataFactory,
                new InitialEventEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqualityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                ExceptionHandler.Instance,
                new EventSynchronizationContextFactory(atypeRepository, btypeRepository, entityRelationDataAccess, mappingParameters.CleanupDuplicateEvents, atypeIdEqualityComparer),
                EqualityComparer <DateTime> .Default,
                EqualityComparer <string> .Default,
                syncStateFactory,
                new EventSynchronizationInterceptorFactory());

            return(new OutlookEventSynchronizer <WebResourceName, string> (synchronizer));
        }
Exemple #8
0
        private IOutlookSynchronizer CreateContactSynchronizer(Options options, GeneralOptions generalOptions, AvailableSynchronizerComponents componentsToFill)
        {
            var atypeRepository = new OutlookContactRepository <ICardDavRepositoryLogger> (
                _outlookSession,
                options.OutlookFolderEntryId,
                options.OutlookFolderStoreId,
                _daslFilterProvider,
                _queryFolderStrategy);

            ICardDavDataAccess cardDavDataAccess;
            var serverUrl = new Uri(options.CalenderUrl);

            IWebDavClient webDavClientOrNullIfFileAccess = null;

            if (serverUrl.Scheme == Uri.UriSchemeFile)
            {
                cardDavDataAccess = new FileSystemDavDataAccess(serverUrl);
            }
            else
            {
                webDavClientOrNullIfFileAccess = CreateWebDavClient(
                    options.UserName,
                    options.GetEffectivePassword(_outlookAccountPasswordProvider),
                    options.CalenderUrl,
                    generalOptions.CalDavConnectTimeout,
                    options.ServerAdapterType,
                    options.CloseAfterEachRequest,
                    options.PreemptiveAuthentication,
                    options.ForceBasicAuthentication,
                    options.ProxyOptions,
                    generalOptions.EnableClientCertificate,
                    generalOptions.AcceptInvalidCharsInServerResponse);

                cardDavDataAccess = new CardDavDataAccess(
                    serverUrl,
                    webDavClientOrNullIfFileAccess,
                    contentType => contentType != "text/x-vlist");
            }
            componentsToFill.CardDavDataAccess = cardDavDataAccess;

            var chunkedExecutor = options.IsChunkedSynchronizationEnabled ? new ChunkedExecutor(options.ChunkSize) : NullChunkedExecutor.Instance;

            var cardDavRepository = new CardDavRepository(
                cardDavDataAccess,
                chunkedExecutor);
            var btypeRepository =
                new LoggingCardDavRepositoryDecorator(
                    cardDavRepository);

            componentsToFill.CardDavEntityRepository = cardDavRepository;

            var mappingParameters = GetMappingParameters <ContactMappingConfiguration> (options);

            var entityMapper = new ContactEntityMapper(mappingParameters);

            var entityRelationDataFactory = new OutlookContactRelationDataFactory();

            var syncStateFactory = new EntitySyncStateFactory <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard, ICardDavRepositoryLogger> (
                entityMapper,
                entityRelationDataFactory,
                ExceptionHandler.Instance);

            var btypeIdEqualityComparer = WebResourceName.Comparer;
            var atypeIdEqulityComparer  = EqualityComparer <string> .Default;

            var storageDataDirectory = _profileDataDirectoryFactory(options.Id);

            var storageDataAccess = new EntityRelationDataAccess <string, DateTime, OutlookContactRelationData, WebResourceName, string> (storageDataDirectory);

            var atypeWriteRepository = BatchEntityRepositoryAdapter.Create(atypeRepository);
            var btypeWriteRepository = BatchEntityRepositoryAdapter.Create(btypeRepository);

            var synchronizer = new Synchronizer <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard, ICardDavRepositoryLogger> (
                atypeRepository,
                btypeRepository,
                atypeWriteRepository,
                btypeWriteRepository,
                InitialSyncStateCreationStrategyFactory <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard, ICardDavRepositoryLogger> .Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution,
                    e => new ContactConflictInitialSyncStateCreationStrategyAutomatic(e)),
                storageDataAccess,
                entityRelationDataFactory,
                new InitialContactEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqulityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                EqualityComparer <DateTime> .Default,
                EqualityComparer <string> .Default,
                syncStateFactory);

            if (mappingParameters.MapDistributionLists)
            {
                CardDavEntityRepository <DistributionList, int, DistributionListSychronizationContext> bDistListRepository;

                // TODO: muss auch für das file funktionieren
                ICardDavDataAccess distListDataAccess = new CardDavDataAccess(
                    serverUrl,
                    webDavClientOrNullIfFileAccess,
                    contentType => contentType == "text/x-vlist");

                componentsToFill.DistListDataAccess = distListDataAccess;

                switch (mappingParameters.DistributionListType)
                {
                case DistributionListType.Sogo:
                    bDistListRepository = new SogoDistributionListRepository(distListDataAccess, chunkedExecutor);
                    break;

                default:
                    throw new NotImplementedException($"{nameof(DistributionListType)} '{mappingParameters.DistributionListType}' not implemented.");
                }

                var distributionListSynchronizer = CreateDistListSynchronizer(options, generalOptions, bDistListRepository);

                return(new OutlookSynchronizer <WebResourceName, string>(
                           new ContactAndDistListSynchronizer(
                               synchronizer,
                               distributionListSynchronizer,
                               new EmailAddressCacheDataAccess(Path.Combine(storageDataDirectory, "emailAddressCache.xml")),
                               btypeRepository,
                               storageDataAccess,
                               atypeRepository,
                               _outlookSession)));
            }
            else
            {
                return(new OutlookSynchronizer <WebResourceName, string>(
                           new ContextCreatingSynchronizerDecorator <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard, ICardDavRepositoryLogger>(
                               synchronizer,
                               new SynchronizationContextFactory <ICardDavRepositoryLogger>(() => NullCardDavRepositoryLogger.Instance))));
            }
        }