Ejemplo n.º 1
0
        public void ApplyRemoteResolution(ISqlDataStore datastore, ISyncSessionInfo syncSessionInfo)
        {
            if (RemoteMergeResolution == null)
            {
                return;
            }

            RemoteMergeResolution.ApplyResolution(datastore, syncSessionInfo);
        }
Ejemplo n.º 2
0
        protected bool Equals(RemoteMergeResolution other)
        {
            if (other == null)
            {
                return(false);
            }

            return(MergeResolutionToApplies.IsEquals(other.MergeResolutionToApplies));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Compute result of conflict between both entity
        /// </summary>
        /// <param name="localDataStore"></param>
        /// <param name="local">Value of entity in local datastore</param>
        /// <param name="remote">Value of entity in remote datastore</param>
        /// <returns>Value of entity to put in remote and local datastore</returns>
        public RemoteMergeResolution Merge(IDataStore localDataStore, object local, object remote)
        {
            LocalEntity    = (T)local;
            RemoteEntity   = (T)remote;
            LocalDataStore = localDataStore;

            var remoteMergeResolution = new RemoteMergeResolution();

            if (LocalEntity == null && RemoteEntity == null)
            {
                return(remoteMergeResolution);
            }

            if (RemoteEntity == null)
            {
                remoteMergeResolution.Insert(LocalDataStore, LocalEntity);
                return(remoteMergeResolution);
            }

            RemoteEntity.LastSyncAt = SyncSessionInfo.HighBoundaryAnchor;

            if (LocalEntity != null && LocalEntity.IsSameEntity(RemoteEntity))
            {
                LocalEntity.LastSyncAt = SyncSessionInfo.HighBoundaryAnchor;
                remoteMergeResolution.Merge(LocalDataStore, LocalEntity, RemoteEntity);
                return(remoteMergeResolution);
            }

            var duplicate = RemoteEntity.FindDuplicateEntity(LocalDataStore);

            if (duplicate != null)
            {
                duplicate.LastSyncAt = SyncSessionInfo.HighBoundaryAnchor;
                remoteMergeResolution.MergeAndKeepLocalIdentity(LocalDataStore, duplicate, RemoteEntity);
                return(remoteMergeResolution);
            }

            if (LocalEntity == null)
            {
                RemoteMergeResolution.InsertInLocal(LocalDataStore, SyncSessionInfo, RemoteEntity);
                return(remoteMergeResolution);
            }

            LocalEntity.LastSyncAt = SyncSessionInfo.HighBoundaryAnchor;
            remoteMergeResolution.MergeDistinctEntity(LocalDataStore, LocalEntity, RemoteEntity);
            return(remoteMergeResolution);
        }
Ejemplo n.º 4
0
        public IdentityChange Resolve(IDataStore localDataStore)
        {
            if (_alreadyMerge)
            {
                return(null);
            }

            var syncableEntity = SyncEntity.Create(_entityInfo);
            var solver         = syncableEntity.GetSolver() as IEntityConflictSolver ?? new DefaultEntitySolver <ISyncable>();

            solver.SyncSessionInfo = _syncSessionInfo;

            var serializer   = _entityInfo.GetSerializer();
            var localEntity  = serializer.Deserialize(_local);
            var remoteEntity = serializer.Deserialize(_remote);

            RemoteMergeResolution = solver.Merge(localDataStore, localEntity, remoteEntity);
            _alreadyMerge         = true;
            return(RemoteMergeResolution.GetIdentityChange());
        }
Ejemplo n.º 5
0
 public override int GetHashCode()
 {
     return(RemoteMergeResolution != null?RemoteMergeResolution.GetHashCode() : 0);
 }