void InitChange(ItemKey key, RecordItemChangeType changeType) { this.Key = key; this.ChangeType = changeType; this.SetChangeID(); this.SetTimestamp(); }
// // In practice, RecordChangeToItem is accessed by SynchronizedStore, which prevents simultaneous changes to // an item by taking an item lock // public void TrackChangeToItem(RecordItem item, RecordItemChangeType changeType) { if (item == null) { throw new ArgumentNullException("item"); } item.Key.ValidateRequired("item.Key"); item.Type.ValidateRequired("item.Type"); this.TrackChange(item.Type.ID, item.Key, changeType); }
public void TrackChange(string typeID, ItemKey key, RecordItemChangeType changeType) { if (string.IsNullOrEmpty(typeID)) { throw new ArgumentException("typeID"); } if (key == null) { throw new ArgumentException("key"); } m_changes[key.ID] = RecordItemChange.UpdateChange(typeID, key, changeType, this.GetChange(key.ID)); }
public static RecordItemChange UpdateChange(string typeID, ItemKey key, RecordItemChangeType changeType, RecordItemChange existingChange) { if (existingChange == null) { return(new RecordItemChange(typeID, key, changeType)); } if (existingChange.ChangeType == RecordItemChangeType.Remove && changeType == RecordItemChangeType.Put) { // Can't put an item already marked for deletion throw new StoreException(StoreErrorNumber.ItemAlreadyDeleted); } if (existingChange.TypeID != typeID) { // Defensive code. Should never happen throw new StoreException(StoreErrorNumber.TypeIDMismatch); } existingChange.InitChange(key, changeType); return(existingChange); }
// TRACK CHANGES for the given typeID & key public IAsyncAction TrackChangeAsync(string typeID, ItemKey key, RecordItemChangeType changeType) { if (string.IsNullOrEmpty(typeID)) { throw new ArgumentException("typeID"); } if (key == null) { throw new ArgumentException("key"); } return(AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { RecordItemChange change = await this.GetChangeAsync(key.ID); change = RecordItemChange.UpdateChange(typeID, key, changeType, change); await this.SaveChangeAsync(change); this.UpdateIndex(key.ID); } })); }
internal RecordItemChange(string typeID, ItemKey key, RecordItemChangeType changeType) { this.TypeID = typeID; this.InitChange(key, changeType); }
public static RecordItemChange UpdateChange(string typeID, ItemKey key, RecordItemChangeType changeType, RecordItemChange existingChange) { if (existingChange == null) { return new RecordItemChange(typeID, key, changeType); } if (existingChange.ChangeType == RecordItemChangeType.Remove && changeType == RecordItemChangeType.Put) { // Can't put an item already marked for deletion throw new StoreException(StoreErrorNumber.ItemAlreadyDeleted); } if (existingChange.TypeID != typeID) { // Defensive code. Should never happen throw new StoreException(StoreErrorNumber.TypeIDMismatch); } existingChange.InitChange(key, changeType); return existingChange; }
// TRACK CHANGES for the given typeID & key public IAsyncAction TrackChangeAsync(string typeID, ItemKey key, RecordItemChangeType changeType) { if (string.IsNullOrEmpty(typeID)) { throw new ArgumentException("typeID"); } if (key == null) { throw new ArgumentException("key"); } return AsyncInfo.Run(async cancelToken => { using (await CrossThreadLockScope.Enter(m_lock)) { RecordItemChange change = await this.GetChangeAsync(key.ID); change = RecordItemChange.UpdateChange(typeID, key, changeType, change); await this.SaveChangeAsync(change); this.UpdateIndex(key.ID); } }); }