public int AddIdentityToSequence(Sequence sequence, int position, Identity identity, DataServiceTransaction dataServiceTransaction) { lock (_objLock) { if (position == -1 || position > sequence.Size) { position = sequence.Add(identity); } else { sequence.Insert(position, identity); } IDictionary sequenceIdMap = _itemIdToSequenceIdMapHash[identity] as IDictionary; if (sequenceIdMap == null) { sequenceIdMap = new Hashtable(); _itemIdToSequenceIdMapHash[identity] = sequenceIdMap; } sequenceIdMap[sequence.Id] = sequence; if (dataServiceTransaction != null) { dataServiceTransaction.GenerateUpdateCollectionMessage(UpdateCollectionRange.InsertIntoCollection, _dataDestination, sequence, position, identity); } return(position); } }
public void RemoveIdentityFromSequence(Sequence sequence, Identity identity, int position, DataServiceTransaction dataServiceTransaction) { if (position == -1) { return; } lock (_objLock) { IDictionary sequenceIdMap = _itemIdToSequenceIdMapHash[identity] as IDictionary; if (sequenceIdMap != null) { sequenceIdMap.Remove(sequence.Id); //Release the item if it does'n occur in any sequence if (sequenceIdMap.Count == 0) { _itemIdToItemHash.Remove(identity); _itemIdToSequenceIdMapHash.Remove(identity); } if (sequence[position].Equals(identity)) { sequence.RemoveAt(position); } else { sequence.Remove(identity); } if (dataServiceTransaction != null) { dataServiceTransaction.GenerateUpdateCollectionMessage(UpdateCollectionRange.DeleteFromCollection, _dataDestination, sequence, position, identity); } } else { _itemIdToItemHash.Remove(identity); sequence.Remove(identity); } } }
public void RemoveIdentityFromSequence(Sequence sequence, Identity identity, int position, DataServiceTransaction dataServiceTransaction) { if (position == -1) return; lock (_objLock) { IDictionary sequenceIdMap = _itemIdToSequenceIdMapHash[identity] as IDictionary; if (sequenceIdMap != null) { sequenceIdMap.Remove(sequence.Id); //Release the item if it does'n occur in any sequence if (sequenceIdMap.Count == 0) { _itemIdToItemHash.Remove(identity); _itemIdToSequenceIdMapHash.Remove(identity); } if (sequence[position].Equals(identity)) sequence.RemoveAt(position); else sequence.Remove(identity); if (dataServiceTransaction != null) dataServiceTransaction.GenerateUpdateCollectionMessage(UpdateCollectionRange.DeleteFromCollection, _dataDestination, sequence, position, identity); } else { _itemIdToItemHash.Remove(identity); sequence.Remove(identity); } } }
public int AddIdentityToSequence(Sequence sequence, int position, Identity identity, DataServiceTransaction dataServiceTransaction) { lock (_objLock) { if (position == -1 || position > sequence.Size) position = sequence.Add(identity); else sequence.Insert(position, identity); IDictionary sequenceIdMap = _itemIdToSequenceIdMapHash[identity] as IDictionary; if (sequenceIdMap == null) { sequenceIdMap = new Hashtable(); _itemIdToSequenceIdMapHash[identity] = sequenceIdMap; } sequenceIdMap[sequence.Id] = sequence; if (dataServiceTransaction != null) dataServiceTransaction.GenerateUpdateCollectionMessage(UpdateCollectionRange.InsertIntoCollection, _dataDestination, sequence, position, identity); return position; } }