Esempio n. 1
0
        public void ProcessedEntity(OfflineEntity entity)
        {
            string           atomId = entity.ServiceMetadata.Id;
            OfflineEntityKey key    = (OfflineEntityKey)entity.GetIdentity();

            key.TypeName = entity.GetType().FullName;

            if (entity.IsTombstone)
            {
                if (String.IsNullOrEmpty(atomId))
                {
                    pkeySet.Add(key);
                }
                else
                {
                    atomIdSet.Add(atomId);
                }
            }
            else
            {
                pkeySet.Add(key);

                if (!String.IsNullOrEmpty(atomId))
                {
                    atomIdSet.Add(atomId);
                }
            }
        }
Esempio n. 2
0
        public bool ContainsEntity(OfflineEntity entity)
        {
            // If the entity is a tombstone, use the atom id
            if (entity.IsTombstone)
            {
                if (String.IsNullOrEmpty(entity.ServiceMetadata.Id))
                {
                    // if it's a tombstone and the id is null, it means it is a delete of
                    // a local insert that can be skipped, so we report it as already written
                    return(true);
                }
                return(atomIdSet.Contains(entity.ServiceMetadata.Id));
            }

            if (!String.IsNullOrEmpty(entity.ServiceMetadata.Id))
            {
                return(atomIdSet.Contains(entity.ServiceMetadata.Id));
            }

            OfflineEntityKey key = (OfflineEntityKey)entity.GetIdentity();

            key.TypeName = entity.GetType().FullName;

            return(pkeySet.Contains(key));
        }
Esempio n. 3
0
        /// <summary>
        /// Uses the snapshot to fill the entity's properties
        /// </summary>
        /// <param name="entity">Entity to fill</param>
        internal void FillEntityFromSnapshot(OfflineEntity entity)
        {
            Type type = entity.GetType();

            foreach (var property in original.Properties)
            {
                PropertyInfo propInfo = type.GetTypeInfo().GetDeclaredProperty(property.Key);

                // If propInfo is null, it's an internal property
                // that will be handled later
                if (propInfo != null)
                {
                    propInfo.SetMethod.Invoke(entity, new[] { property.Value });
                }
            }

            // Get the internal properties
            entity.entityMetadata = original.Metadata;
            entity.EntityState    = original.EntityState;
            entity.TickCount      = original.TickCount;
        }
Esempio n. 4
0
        /// <summary>
        /// Method called by the context to resolve a conflict with StoreItemWins
        /// </summary>
        /// <param name="entity"></param>
        public void ResolveStoreConflictByRollback(OfflineEntity entity)
        {
            Type type = entity.GetType();

            Collections[type].ResolveConflictByRollback(entity);
        }
Esempio n. 5
0
        /// <summary>
        /// Uses the snapshot to fill the entity's properties
        /// </summary>
        /// <param name="entity">Entity to fill</param>
        internal void FillEntityFromSnapshot(OfflineEntity entity)
        {
            Type type = entity.GetType();
            foreach (var property in original.Properties)
            {
                PropertyInfo propInfo = type.GetTypeInfo().GetDeclaredProperty(property.Key);

                // If propInfo is null, it's an internal property
                // that will be handled later
                if (propInfo != null)
                {
                    propInfo.SetMethod.Invoke(entity, new[] { property.Value });
                }
            }

            // Get the internal properties
            entity.entityMetadata = original.Metadata;
            entity.EntityState = original.EntityState;
            entity.TickCount = original.TickCount;
        }
Esempio n. 6
0
 public void AddSerializedDownloadItem(OfflineEntity entity)
 {
     entity.EntityState = OfflineEntityState.Unmodified;
     // Pass the entity to the collection
     Collections[entity.GetType()].AddOrUpdateSyncEntity(entity);
 }
Esempio n. 7
0
 public void AddSerializedLocalChange(OfflineEntity entity)
 {
     entity.EntityState = OfflineEntityState.Saved;
     Collections[entity.GetType()].AddSerializedEntity(entity);
 }
Esempio n. 8
0
        /// <summary>
        /// Method called by the context to resolve a conflict with StoreItemWins
        /// </summary>
        /// <param name="entity"></param>
        public void ResolveStoreConflictByRollback(OfflineEntity entity)
        {
            Type type = entity.GetType();

            Collections[type].ResolveConflictByRollback(entity);            
        }
Esempio n. 9
0
 public void AddSerializedDownloadItem(OfflineEntity entity)
 {
     entity.EntityState = OfflineEntityState.Unmodified;
     // Pass the entity to the collection
     Collections[entity.GetType()].AddOrUpdateSyncEntity(entity);
 }
Esempio n. 10
0
 public void AddSerializedLocalChange(OfflineEntity entity)
 {
     entity.EntityState = OfflineEntityState.Saved;
     Collections[entity.GetType()].AddSerializedEntity(entity);
 }