示例#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);
                }
            }
        }
示例#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));
        }
示例#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;
        }
示例#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);
        }
示例#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;
        }
示例#6
0
 public void AddSerializedDownloadItem(OfflineEntity entity)
 {
     entity.EntityState = OfflineEntityState.Unmodified;
     // Pass the entity to the collection
     Collections[entity.GetType()].AddOrUpdateSyncEntity(entity);
 }
示例#7
0
 public void AddSerializedLocalChange(OfflineEntity entity)
 {
     entity.EntityState = OfflineEntityState.Saved;
     Collections[entity.GetType()].AddSerializedEntity(entity);
 }
示例#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);            
        }
示例#9
0
 public void AddSerializedDownloadItem(OfflineEntity entity)
 {
     entity.EntityState = OfflineEntityState.Unmodified;
     // Pass the entity to the collection
     Collections[entity.GetType()].AddOrUpdateSyncEntity(entity);
 }
示例#10
0
 public void AddSerializedLocalChange(OfflineEntity entity)
 {
     entity.EntityState = OfflineEntityState.Saved;
     Collections[entity.GetType()].AddSerializedEntity(entity);
 }