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