public static IInitialSyncStateCreationStrategy<string, DateTime, ContactItemWrapper, Uri, string, vCard> Create (IEntitySyncStateFactory<string, DateTime, ContactItemWrapper, Uri, string, vCard> syncStateFactory, EntitySyncStateEnvironment<string, DateTime, ContactItemWrapper, Uri, string, vCard> environment, SynchronizationMode synchronizationMode, ConflictResolution conflictResolution)
 {
   switch (synchronizationMode)
   {
     case SynchronizationMode.MergeInBothDirections:
       var conflictResolutionStrategy = Create (syncStateFactory, environment, conflictResolution);
       return new TwoWayInitialSyncStateCreationStrategy<string, DateTime, ContactItemWrapper, Uri, string, vCard> (
           syncStateFactory,
           conflictResolutionStrategy
           );
     case SynchronizationMode.ReplicateOutlookIntoServer:
     case SynchronizationMode.MergeOutlookIntoServer:
       return new OneWayInitialSyncStateCreationStrategy_AToB<string, DateTime, ContactItemWrapper, Uri, string, vCard> (
           syncStateFactory,
           synchronizationMode == SynchronizationMode.ReplicateOutlookIntoServer ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
           );
     case SynchronizationMode.ReplicateServerIntoOutlook:
     case SynchronizationMode.MergeServerIntoOutlook:
       return new OneWayInitialSyncStateCreationStrategy_BToA<string, DateTime, ContactItemWrapper, Uri, string, vCard> (
           syncStateFactory,
           synchronizationMode == SynchronizationMode.ReplicateServerIntoOutlook ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
           );
   }
   throw new NotImplementedException();
 }
Ejemplo n.º 2
0
 public EntitySyncStateEnvironment(IEntityMapper <TAtypeEntity, TBtypeEntity, TContext> mapper, IEntityRelationDataFactory <TAtypeEntityId, TAtypeEntityVersion, TBtypeEntityId, TBtypeEntityVersion> dataFactory, IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> stateFactory, IExceptionLogger exceptionLogger)
 {
     ExceptionLogger = exceptionLogger;
     Mapper          = mapper;
     DataFactory     = dataFactory;
     StateFactory    = stateFactory;
 }
Ejemplo n.º 3
0
 public Synchronizer(
     IReadOnlyEntityRepository <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TContext> atypeRepository,
     IReadOnlyEntityRepository <TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> btypeRepository,
     IBatchWriteOnlyEntityRepository <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TContext> atypeWriteRepository,
     IBatchWriteOnlyEntityRepository <TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> btypeWriteRepository,
     IInitialSyncStateCreationStrategy <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> initialSyncStateCreationStrategy,
     IEntityRelationDataAccess <TAtypeEntityId, TAtypeEntityVersion, TBtypeEntityId, TBtypeEntityVersion> entityRelationDataAccess,
     IEntityRelationDataFactory <TAtypeEntityId, TAtypeEntityVersion, TBtypeEntityId, TBtypeEntityVersion> entityRelationDataFactory,
     IInitialEntityMatcher <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> initialEntityMatcher,
     IEqualityComparer <TAtypeEntityId> atypeIdComparer, IEqualityComparer <TBtypeEntityId> btypeIdComparer,
     ITotalProgressFactory totalProgressFactory,
     IEqualityComparer <TAtypeEntityVersion> atypeVersionComparer,
     IEqualityComparer <TBtypeEntityVersion> btypeVersionComparer, IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> syncStateFactory,
     ISynchronizationInterceptorFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> synchronizationInterceptorFactory = null)
 {
     _initialSyncStateCreationStrategy = initialSyncStateCreationStrategy;
     _totalProgressFactory             = totalProgressFactory;
     _atypeIdComparer      = atypeIdComparer;
     _btypeIdComparer      = btypeIdComparer;
     _atypeVersionComparer = atypeVersionComparer;
     _btypeVersionComparer = btypeVersionComparer;
     _syncStateFactory     = syncStateFactory;
     _synchronizationInterceptorFactory = synchronizationInterceptorFactory ?? NullSynchronizationInterceptorFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> .Instance;
     _atypeWriteRepository      = atypeWriteRepository;
     _btypeWriteRepository      = btypeWriteRepository;
     _atypeRepository           = atypeRepository;
     _btypeRepository           = btypeRepository;
     _entityRelationDataAccess  = entityRelationDataAccess;
     _entityRelationDataFactory = entityRelationDataFactory;
     _initialEntityMatcher      = initialEntityMatcher;
 }
        public static IInitialSyncStateCreationStrategy <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> Create(
            IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> syncStateFactory,
            EntitySyncStateEnvironment <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> environment,
            SynchronizationMode synchronizationMode,
            ConflictResolution conflictResolution,
            Func <
                EntitySyncStateEnvironment <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity>,
                ConflictInitialSyncStateCreationStrategyAutomatic <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> > automaticConflictResolutionStrategyFactory)
        {
            switch (synchronizationMode)
            {
            case SynchronizationMode.MergeInBothDirections:
                var conflictResolutionStrategy = Create(syncStateFactory, environment, conflictResolution, automaticConflictResolutionStrategyFactory);
                return(new TwoWayInitialSyncStateCreationStrategy <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> (
                           syncStateFactory,
                           conflictResolutionStrategy
                           ));

            case SynchronizationMode.ReplicateOutlookIntoServer:
            case SynchronizationMode.MergeOutlookIntoServer:
                return(new OneWayInitialSyncStateCreationStrategy_AToB <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> (
                           syncStateFactory,
                           synchronizationMode == SynchronizationMode.ReplicateOutlookIntoServer ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
                           ));

            case SynchronizationMode.ReplicateServerIntoOutlook:
            case SynchronizationMode.MergeServerIntoOutlook:
                return(new OneWayInitialSyncStateCreationStrategy_BToA <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> (
                           syncStateFactory,
                           synchronizationMode == SynchronizationMode.ReplicateServerIntoOutlook ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
                           ));
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 5
0
 public EntitySyncStateEnvironment(IEntityMapper <TAtypeEntity, TBtypeEntity> mapper, IWriteOnlyEntityRepository <TAtypeEntity, TAtypeEntityId, TAtypeEntityVersion> aRepository, IWriteOnlyEntityRepository <TBtypeEntity, TBtypeEntityId, TBtypeEntityVersion> bRepository, IEntityRelationDataFactory <TAtypeEntityId, TAtypeEntityVersion, TBtypeEntityId, TBtypeEntityVersion> dataFactory, IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> stateFactory, IExceptionLogger exceptionLogger)
 {
     ExceptionLogger = exceptionLogger;
     Mapper          = mapper;
     ARepository     = aRepository;
     BRepository     = bRepository;
     DataFactory     = dataFactory;
     StateFactory    = stateFactory;
 }
 public virtual void Setup()
 {
     _synchronizerSetup = new TestSynchronizerSetup();
     _factory           = new EntitySyncStateFactory <string, int, string, string, int, string> (
         _synchronizerSetup.EntityMapper,
         _synchronizerSetup.AtypeRepository,
         _synchronizerSetup.BtypeRepository,
         _synchronizerSetup.EntityRelationDataFactory,
         MockRepository.GenerateMock <IExceptionLogger> ()
         );
 }
 public virtual void Setup()
 {
     _synchronizerSetup = new TestSynchronizerSetup();
       _factory = new EntitySyncStateFactory<string, int, string, string, int, string> (
       _synchronizerSetup.EntityMapper,
       _synchronizerSetup.AtypeRepository,
       _synchronizerSetup.BtypeRepository,
       _synchronizerSetup.EntityRelationDataFactory,
        MockRepository.GenerateMock<IExceptionLogger> ()
       );
 }
    private static IConflictInitialSyncStateCreationStrategy<string, DateTime, ContactItemWrapper, Uri, string, vCard> Create (IEntitySyncStateFactory<string, DateTime, ContactItemWrapper, Uri, string, vCard> syncStateFactory, EntitySyncStateEnvironment<string, DateTime, ContactItemWrapper, Uri, string, vCard> environment, ConflictResolution conflictResolution)
    {
      switch (conflictResolution)
      {
        case ConflictResolution.OutlookWins:
          return new ConflictInitialSyncStateCreationStrategyAWins<string, DateTime, ContactItemWrapper, Uri, string, vCard> (syncStateFactory);
        case ConflictResolution.ServerWins:
          return new ConflictInitialSyncStateCreationStrategyBWins<string, DateTime, ContactItemWrapper, Uri, string, vCard> (syncStateFactory);
        case ConflictResolution.Automatic:
          return new ContactConflictInitialSyncStateCreationStrategyAutomatic (environment);
      }

      throw new NotImplementedException();
    }
    private static IConflictInitialSyncStateCreationStrategy<string, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> Create (IEntitySyncStateFactory<string, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> syncStateFactory, EntitySyncStateEnvironment<string, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> environment, ConflictResolution conflictResolution)
    {
      switch (conflictResolution)
      {
        case ConflictResolution.OutlookWins:
          return new ConflictInitialSyncStateCreationStrategyAWins<string, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> (syncStateFactory);
        case ConflictResolution.ServerWins:
          return new ConflictInitialSyncStateCreationStrategyBWins<string, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> (syncStateFactory);
        case ConflictResolution.Automatic:
          return new EventConflictInitialSyncStateCreationStrategyAutomatic (environment);
      }

      throw new NotImplementedException();
    }
Ejemplo n.º 10
0
        public void Setup()
        {
            _entityRelationData        = new List <EntityRelationData>();
            _localRepository           = new TestRepository("l");
            _serverRepository          = new TestRepository("s");
            _entityRelationDataFactory = new EntityRelationDataFactory();

            _factory = new EntitySyncStateFactory <Identifier, int, string, Identifier, int, string, int> (
                new Mapper(),
                _entityRelationDataFactory,
                MockRepository.GenerateMock <IExceptionLogger>()
                );

            _entityRelationDataAccess = MockRepository.GenerateStub <IEntityRelationDataAccess <Identifier, int, Identifier, int> >();
            _entityRelationDataAccess.Stub(d => d.LoadEntityRelationData()).WhenCalled(a => a.ReturnValue = _entityRelationData.ToArray());
            _entityRelationDataAccess
            .Stub(d => d.SaveEntityRelationData(null))
            .IgnoreArguments()
            .WhenCalled(a => { _entityRelationData = ((List <IEntityRelationData <Identifier, int, Identifier, int> >)a.Arguments[0]).Cast <EntityRelationData>().ToList(); });
        }
    public void Setup ()
    {
      _entityRelationData = new List<EntityRelationData>();
      _localRepository = new TestRepository ("l");
      _serverRepository = new TestRepository ("s");
      _entityRelationDataFactory = new EntityRelationDataFactory();

      _factory = new EntitySyncStateFactory<Identifier, int, string, Identifier, int, string> (
          new Mapper(),
          _entityRelationDataFactory,
          MockRepository.GenerateMock<IExceptionLogger>()
          );

      _entityRelationDataAccess = MockRepository.GenerateStub<IEntityRelationDataAccess<Identifier, int, Identifier, int>>();
      _entityRelationDataAccess.Stub (d => d.LoadEntityRelationData()).WhenCalled (a => a.ReturnValue = _entityRelationData.ToArray());
      _entityRelationDataAccess
          .Stub (d => d.SaveEntityRelationData (null))
          .IgnoreArguments()
          .WhenCalled (a => { _entityRelationData = ((List<IEntityRelationData<Identifier, int, Identifier, int>>) a.Arguments[0]).Cast<EntityRelationData>().ToList(); });
    }
        public List <IEntitySyncState <AppointmentId, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> > TransformInitialCreatedStates(
            List <IEntitySyncState <AppointmentId, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> > states,
            IEntitySyncStateFactory <AppointmentId, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> stateFactory)
        {
            _deletesInByGlobalAppointmentId = new Dictionary <string, DeleteInB <AppointmentId, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> >();
            _createsInByGlobalAppointmentId = new Dictionary <string, CreateInB <AppointmentId, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> >();

            foreach (var state in states)
            {
                state.Accept(this);
            }

            foreach (var kvpDelete in _deletesInByGlobalAppointmentId)
            {
                CreateInB <AppointmentId, DateTime, AppointmentItemWrapper, WebResourceName, string, IICalendar> create;
                if (_createsInByGlobalAppointmentId.TryGetValue(kvpDelete.Key, out create))
                {
                    s_logger.Info($"Converting deletion of '{kvpDelete.Value.KnownData.BtypeId.OriginalAbsolutePath}' and creation of new from '{create.AId}' into an update.");

                    // TODO: removes are inefficient O(n) ops!!
                    states.Remove(kvpDelete.Value);
                    states.Remove(create);
                    states.Add(
                        stateFactory.Create_UpdateAtoB(
                            new OutlookEventRelationData
                    {
                        AtypeId      = create.AId,
                        AtypeVersion = create.AVersion,
                        BtypeId      = kvpDelete.Value.KnownData.BtypeId,
                        BtypeVersion = kvpDelete.Value.KnownData.BtypeVersion
                    },
                            create.AVersion,
                            kvpDelete.Value.KnownData.BtypeVersion));
                }
            }

            _deletesInByGlobalAppointmentId = null;
            _createsInByGlobalAppointmentId = null;

            return(states);
        }
        private static IConflictInitialSyncStateCreationStrategy <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> Create(
            IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> syncStateFactory,
            EntitySyncStateEnvironment <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> environment,
            ConflictResolution conflictResolution,
            Func <
                EntitySyncStateEnvironment <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity>,
                ConflictInitialSyncStateCreationStrategyAutomatic <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> > automaticConflictResolutionStrategyFactory)
        {
            switch (conflictResolution)
            {
            case ConflictResolution.OutlookWins:
                return(new ConflictInitialSyncStateCreationStrategyAWins <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> (syncStateFactory));

            case ConflictResolution.ServerWins:
                return(new ConflictInitialSyncStateCreationStrategyBWins <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> (syncStateFactory));

            case ConflictResolution.Automatic:
                return(automaticConflictResolutionStrategyFactory(environment));
            }

            throw new NotImplementedException();
        }
Ejemplo n.º 14
0
        public void TransformInitialCreatedStates(
            IReadOnlyList <IEntitySyncStateContext <AppointmentId, DateTime, IAppointmentItemWrapper, WebResourceName, string, IICalendar, IEventSynchronizationContext> > syncStateContexts,
            IEntitySyncStateFactory <AppointmentId, DateTime, IAppointmentItemWrapper, WebResourceName, string, IICalendar, IEventSynchronizationContext> stateFactory)
        {
            _deletesInByGlobalAppointmentId = new Dictionary <string, ContextWithDelete>();
            _createsInByGlobalAppointmentId = new Dictionary <string, ContextWithCreate>();

            foreach (var state in syncStateContexts)
            {
                state.Accept(this);
            }

            foreach (var kvpDelete in _deletesInByGlobalAppointmentId)
            {
                ContextWithCreate create;
                if (_createsInByGlobalAppointmentId.TryGetValue(kvpDelete.Key, out create))
                {
                    s_logger.Info($"Converting deletion of '{kvpDelete.Value.State.KnownData.BtypeId.OriginalAbsolutePath}' and creation of new from '{create.State.AId}' into an update.");

                    kvpDelete.Value.Context.SetState(stateFactory.Create_Discard());

                    create.Context.SetState(stateFactory.Create_UpdateAtoB(
                                                new OutlookEventRelationData
                    {
                        AtypeId      = create.State.AId,
                        AtypeVersion = create.State.AVersion,
                        BtypeId      = kvpDelete.Value.State.KnownData.BtypeId,
                        BtypeVersion = kvpDelete.Value.State.KnownData.BtypeVersion
                    },
                                                create.State.AVersion,
                                                kvpDelete.Value.State.KnownData.BtypeVersion));
                }
            }

            _deletesInByGlobalAppointmentId = null;
            _createsInByGlobalAppointmentId = null;
        }
 public void TransformInitialCreatedStates(IReadOnlyList <IEntitySyncStateContext <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> > syncStateContexts, IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> stateFactory)
 {
 }
Ejemplo n.º 16
0
        public static IInitialSyncStateCreationStrategy <string, DateTime, TaskItemWrapper, string, string, Task> Create(IEntitySyncStateFactory <string, DateTime, TaskItemWrapper, string, string, Task> syncStateFactory, EntitySyncStateEnvironment <string, DateTime, TaskItemWrapper, string, string, Task> environment, SynchronizationMode synchronizationMode, ConflictResolution conflictResolution)
        {
            switch (synchronizationMode)
            {
            case SynchronizationMode.MergeInBothDirections:
                var conflictResolutionStrategy = Create(syncStateFactory, environment, conflictResolution);
                return(new TwoWayInitialSyncStateCreationStrategy <string, DateTime, TaskItemWrapper, string, string, Task> (
                           syncStateFactory,
                           conflictResolutionStrategy
                           ));

            case SynchronizationMode.ReplicateOutlookIntoServer:
            case SynchronizationMode.MergeOutlookIntoServer:
                return(new OneWayInitialSyncStateCreationStrategy_AToB <string, DateTime, TaskItemWrapper, string, string, Task> (
                           syncStateFactory,
                           synchronizationMode == SynchronizationMode.ReplicateOutlookIntoServer ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
                           ));

            case SynchronizationMode.ReplicateServerIntoOutlook:
            case SynchronizationMode.MergeServerIntoOutlook:
                return(new OneWayInitialSyncStateCreationStrategy_BToA <string, DateTime, TaskItemWrapper, string, string, Task> (
                           syncStateFactory,
                           synchronizationMode == SynchronizationMode.ReplicateServerIntoOutlook ? OneWaySyncMode.Replicate : OneWaySyncMode.Merge
                           ));
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 17
0
        private static IConflictInitialSyncStateCreationStrategy <string, DateTime, TaskItemWrapper, string, string, Task> Create(IEntitySyncStateFactory <string, DateTime, TaskItemWrapper, string, string, Task> syncStateFactory, EntitySyncStateEnvironment <string, DateTime, TaskItemWrapper, string, string, Task> environment, ConflictResolution conflictResolution)
        {
            switch (conflictResolution)
            {
            case ConflictResolution.OutlookWins:
                return(new ConflictInitialSyncStateCreationStrategyAWins <string, DateTime, TaskItemWrapper, string, string, Task> (syncStateFactory));

            case ConflictResolution.ServerWins:
                return(new ConflictInitialSyncStateCreationStrategyBWins <string, DateTime, TaskItemWrapper, string, string, Task> (syncStateFactory));

            case ConflictResolution.Automatic:
                return(new GoogleTaskConflictInitialSyncStateCreationStrategyAutomatic(environment));
            }

            throw new NotImplementedException();
        }
 public OneWayInitialSyncStateCreationStrategy_BToA(IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> factory, OneWaySyncMode syncMode)
 {
     _factory  = factory;
     _syncMode = syncMode;
 }
Ejemplo n.º 19
0
 public TwoWayInitialSyncStateCreationStrategy(IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> factory, IConflictInitialSyncStateCreationStrategy <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> conflictInitialStateCreationStrategy)
 {
     _stateFactory = factory;
     _conflictInitialStateCreationStrategy = conflictInitialStateCreationStrategy;
 }
Ejemplo n.º 20
0
 public List <IEntitySyncState <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> > TransformInitialCreatedStates(List <IEntitySyncState <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> > states, IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> stateFactory)
 {
     return(states);
 }
Ejemplo n.º 21
0
 public ConflictInitialSyncStateCreationStrategyBWins(IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity> factory)
 {
     _factory = factory;
 }
        public Synchronizer(
            IReadOnlyEntityRepository <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TContext> atypeRepository,
            IReadOnlyEntityRepository <TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> btypeRepository,
            IBatchWriteOnlyEntityRepository <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TContext> atypeWriteRepository,
            IBatchWriteOnlyEntityRepository <TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> btypeWriteRepository,
            IInitialSyncStateCreationStrategy <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> initialSyncStateCreationStrategy,
            IEntityRelationDataAccess <TAtypeEntityId, TAtypeEntityVersion, TBtypeEntityId, TBtypeEntityVersion> entityRelationDataAccess,
            IEntityRelationDataFactory <TAtypeEntityId, TAtypeEntityVersion, TBtypeEntityId, TBtypeEntityVersion> entityRelationDataFactory,
            IInitialEntityMatcher <TAtypeEntityId, TAtypeEntityVersion, TAMatchData, TBtypeEntityId, TBtypeEntityVersion, TBMatchData> initialEntityMatcher,
            IEqualityComparer <TAtypeEntityId> atypeIdComparer, IEqualityComparer <TBtypeEntityId> btypeIdComparer,
            ITotalProgressFactory totalProgressFactory,
            IEqualityComparer <TAtypeEntityVersion> atypeVersionComparer,
            IEqualityComparer <TBtypeEntityVersion> btypeVersionComparer, IEntitySyncStateFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> syncStateFactory,
            IExceptionHandlingStrategy exceptionHandlingStrategy,
            IMatchDataFactory <TAtypeEntity, TAMatchData> aMatchDataFactory,
            IMatchDataFactory <TBtypeEntity, TBMatchData> bMatchDataFactory,
            int?chunkSize,
            IChunkedExecutor chunkedExecutor,
            IFullEntitySynchronizationLoggerFactory <TAtypeEntity, TBtypeEntity> fullEntitySynchronizationLoggerFactory,
            IStateAwareEntityRepository <TAtypeEntityId, TAtypeEntityVersion, TContext, TAtypeStateToken> atypeStateAwareEntityRepository,
            IStateAwareEntityRepository <TBtypeEntityId, TBtypeEntityVersion, TContext, TBtypeStateToken> btypeStateAwareEntityRepository,
            IStateTokenDataAccess <TAtypeStateToken, TBtypeStateToken> stateTokenDataAccess,
            ISynchronizationInterceptorFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> synchronizationInterceptorFactoryOrNull = null)
        {
            if (atypeRepository == null)
            {
                throw new ArgumentNullException(nameof(atypeRepository));
            }
            if (btypeRepository == null)
            {
                throw new ArgumentNullException(nameof(btypeRepository));
            }
            if (atypeWriteRepository == null)
            {
                throw new ArgumentNullException(nameof(atypeWriteRepository));
            }
            if (btypeWriteRepository == null)
            {
                throw new ArgumentNullException(nameof(btypeWriteRepository));
            }
            if (initialSyncStateCreationStrategy == null)
            {
                throw new ArgumentNullException(nameof(initialSyncStateCreationStrategy));
            }
            if (entityRelationDataAccess == null)
            {
                throw new ArgumentNullException(nameof(entityRelationDataAccess));
            }
            if (entityRelationDataFactory == null)
            {
                throw new ArgumentNullException(nameof(entityRelationDataFactory));
            }
            if (initialEntityMatcher == null)
            {
                throw new ArgumentNullException(nameof(initialEntityMatcher));
            }
            if (atypeIdComparer == null)
            {
                throw new ArgumentNullException(nameof(atypeIdComparer));
            }
            if (btypeIdComparer == null)
            {
                throw new ArgumentNullException(nameof(btypeIdComparer));
            }
            if (totalProgressFactory == null)
            {
                throw new ArgumentNullException(nameof(totalProgressFactory));
            }
            if (atypeVersionComparer == null)
            {
                throw new ArgumentNullException(nameof(atypeVersionComparer));
            }
            if (btypeVersionComparer == null)
            {
                throw new ArgumentNullException(nameof(btypeVersionComparer));
            }
            if (syncStateFactory == null)
            {
                throw new ArgumentNullException(nameof(syncStateFactory));
            }
            if (exceptionHandlingStrategy == null)
            {
                throw new ArgumentNullException(nameof(exceptionHandlingStrategy));
            }
            if (aMatchDataFactory == null)
            {
                throw new ArgumentNullException(nameof(aMatchDataFactory));
            }
            if (bMatchDataFactory == null)
            {
                throw new ArgumentNullException(nameof(bMatchDataFactory));
            }
            if (fullEntitySynchronizationLoggerFactory == null)
            {
                throw new ArgumentNullException(nameof(fullEntitySynchronizationLoggerFactory));
            }
            if (atypeStateAwareEntityRepository == null)
            {
                throw new ArgumentNullException(nameof(atypeStateAwareEntityRepository));
            }
            if (btypeStateAwareEntityRepository == null)
            {
                throw new ArgumentNullException(nameof(btypeStateAwareEntityRepository));
            }
            if (stateTokenDataAccess == null)
            {
                throw new ArgumentNullException(nameof(stateTokenDataAccess));
            }

            _chunkSize       = chunkSize;
            _chunkedExecutor = chunkedExecutor;
            _fullEntitySynchronizationLoggerFactory = fullEntitySynchronizationLoggerFactory;
            _atypeStateAwareEntityRepository        = atypeStateAwareEntityRepository;
            _btypeStateAwareEntityRepository        = btypeStateAwareEntityRepository;
            _stateTokenDataAccess = stateTokenDataAccess;

            _initialSyncStateCreationStrategy = initialSyncStateCreationStrategy;
            _totalProgressFactory             = totalProgressFactory;
            _atypeIdComparer                   = atypeIdComparer;
            _btypeIdComparer                   = btypeIdComparer;
            _atypeVersionComparer              = atypeVersionComparer;
            _btypeVersionComparer              = btypeVersionComparer;
            _syncStateFactory                  = syncStateFactory;
            _exceptionHandlingStrategy         = exceptionHandlingStrategy;
            _aMatchDataFactory                 = aMatchDataFactory;
            _bMatchDataFactory                 = bMatchDataFactory;
            _synchronizationInterceptorFactory = synchronizationInterceptorFactoryOrNull ?? NullSynchronizationInterceptorFactory <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext> .Instance;
            _atypeWriteRepository              = atypeWriteRepository;
            _btypeWriteRepository              = btypeWriteRepository;
            _atypeRepository                   = atypeRepository;
            _btypeRepository                   = btypeRepository;
            _entityRelationDataAccess          = entityRelationDataAccess;
            _entityRelationDataFactory         = entityRelationDataFactory;
            _initialEntityMatcher              = initialEntityMatcher;
            _entitySyncStateChunkCreator       = new EntitySyncStateChunkCreator <TAtypeEntityId, TAtypeEntityVersion, TAtypeEntity, TBtypeEntityId, TBtypeEntityVersion, TBtypeEntity, TContext>(chunkSize);
        }
        private static IConflictInitialSyncStateCreationStrategy <string, DateTime, GenericComObjectWrapper <ContactItem>, Uri, string, vCard> Create(IEntitySyncStateFactory <string, DateTime, GenericComObjectWrapper <ContactItem>, Uri, string, vCard> syncStateFactory, EntitySyncStateEnvironment <string, DateTime, GenericComObjectWrapper <ContactItem>, Uri, string, vCard> environment, ConflictResolution conflictResolution)
        {
            switch (conflictResolution)
            {
            case ConflictResolution.OutlookWins:
                return(new ConflictInitialSyncStateCreationStrategyAWins <string, DateTime, GenericComObjectWrapper <ContactItem>, Uri, string, vCard> (syncStateFactory));

            case ConflictResolution.ServerWins:
                return(new ConflictInitialSyncStateCreationStrategyBWins <string, DateTime, GenericComObjectWrapper <ContactItem>, Uri, string, vCard> (syncStateFactory));

            case ConflictResolution.Automatic:
                return(new ContactConflictInitialSyncStateCreationStrategyAutomatic(environment));
            }

            throw new NotImplementedException();
        }
        private static IConflictInitialSyncStateCreationStrategy <string, DateTime, AppointmentItemWrapper, Uri, string, IICalendar> Create(IEntitySyncStateFactory <string, DateTime, AppointmentItemWrapper, Uri, string, IICalendar> syncStateFactory, EntitySyncStateEnvironment <string, DateTime, AppointmentItemWrapper, Uri, string, IICalendar> environment, ConflictResolution conflictResolution)
        {
            switch (conflictResolution)
            {
            case ConflictResolution.OutlookWins:
                return(new ConflictInitialSyncStateCreationStrategyAWins <string, DateTime, AppointmentItemWrapper, Uri, string, IICalendar> (syncStateFactory));

            case ConflictResolution.ServerWins:
                return(new ConflictInitialSyncStateCreationStrategyBWins <string, DateTime, AppointmentItemWrapper, Uri, string, IICalendar> (syncStateFactory));

            case ConflictResolution.Automatic:
                return(new EventConflictInitialSyncStateCreationStrategyAutomatic(environment));
            }

            throw new NotImplementedException();
        }