コード例 #1
0
        private OutlookSynchronizer CreateContactSynchronizer(Options options)
        {
            var atypeRepository = new OutlookContactRepository(
                _outlookSession,
                options.OutlookFolderEntryId,
                options.OutlookFolderStoreId);


            IEntityRepository <vCard, Uri, string> btypeRepository = new CardDavRepository(
                new CardDavDataAccess(
                    new Uri(options.CalenderUrl),
                    CreateWebDavClient(
                        options.UserName,
                        options.Password,
                        _calDavConnectTimeout,
                        options.ServerAdapterType,
                        options.CloseAfterEachRequest,
                        options.ProxyOptions)));

            var mappingParameters = GetMappingParameters <ContactMappingConfiguration> (options);

            var entityMapper = new ContactEntityMapper(mappingParameters);

            var entityRelationDataFactory = new OutlookContactRelationDataFactory();

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

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

            var storageDataDirectory = _profileDataDirectoryFactory(options.Id);

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

            var synchronizer = new Synchronizer <string, DateTime, ContactItemWrapper, Uri, string, vCard> (
                atypeRepository,
                btypeRepository,
                InitialContactSyncStateCreationStrategyFactory.Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution),
                storageDataAccess,
                entityRelationDataFactory,
                new InitialContactEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqulityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                ExceptionHandler.Instance);

            return(new OutlookSynchronizer(synchronizer, atypeRepository));
        }
コード例 #2
0
        private IOutlookSynchronizer CreateContactSynchronizer(Options options, AvailableSynchronizerComponents componentsToFill)
        {
            var atypeRepository = new OutlookContactRepository(
                _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));

            componentsToFill.CardDavDataAccess = cardDavDataAccess;

            IEntityRepository <vCard, WebResourceName, string> 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,
                atypeRepository,
                btypeRepository,
                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 synchronizer = new Synchronizer <string, DateTime, ContactItemWrapper, WebResourceName, string, vCard> (
                atypeRepository,
                btypeRepository,
                InitialContactSyncStateCreationStrategyFactory.Create(
                    syncStateFactory,
                    syncStateFactory.Environment,
                    options.SynchronizationMode,
                    options.ConflictResolution),
                storageDataAccess,
                entityRelationDataFactory,
                new InitialContactEntityMatcher(btypeIdEqualityComparer),
                atypeIdEqulityComparer,
                btypeIdEqualityComparer,
                _totalProgressFactory,
                ExceptionHandler.Instance);

            return(new OutlookSynchronizer <WebResourceName, string> (synchronizer));
        }