Ejemplo n.º 1
0
 /// <summary>
 /// Remove ObjectToRemove from the Collection if found, else throws an exception
 /// </summary>
 public void Remove(object item)
 {
     if (!Contains(item))
     {
         return;
     }
     Sop.DataBlock currBlock = this.GetCurrentDataBlock(true);
     if (GetId(currBlock) >= 0)
     {
         MruManager.Remove(GetId(currBlock), true);
     }
     DataBlockDriver.Remove(this, currBlock);
 }
Ejemplo n.º 2
0
 //internal override bool RemoveInMemory(long DataAddress, Transaction.ITransactionLogger Transaction)
 //{
 //    if (LastItem != null)
 //        LastItem.Clear();
 //    if (FirstItem != null)
 //        FirstItem.Clear();
 //    CurrentItem = null;
 //    base.RemoveInMemory(DataAddress, Transaction);
 //    return true;
 //}
 private void RemoveAt(long dataAddress, bool willMove)
 {
     if (willMove && !MoveTo(dataAddress))
     {
         return;
     }
     if (IsDeletedBlocksList && Count == 1)
     {
         return;
     }
     Sop.DataBlock currBlock = this.GetCurrentDataBlock(true);
     if (FirstItem.DiskBuffer.DataAddress == dataAddress)
     {
         MoveFirst();
         if (MoveNext())
         {
             FirstItem.DiskBuffer.DataAddress = CurrentItem.DiskBuffer.DataAddress;
             CurrentItem.PreviousItemAddress  = -1;
             Sop.DataBlock db = WriteToBlock(CurrentItem, CurrentItem.DiskBuffer);
             DataBlockDriver.SetDiskBlock(this, db, false);
         }
         else
         {
             long address = FirstItem.DiskBuffer.DataAddress;
             FirstItem.DiskBuffer.DataAddress = LastItem.DiskBuffer.DataAddress = -1;
             CurrentItem = FirstItem;
             Sop.DataBlock db = WriteToBlock(CurrentItem, CurrentItem.DiskBuffer);
             db.DataAddress = address;
             DataBlockDriver.SetDiskBlock(this, db, false);
             db.DataAddress = -1;
         }
     }
     else if (LastItem.DiskBuffer.DataAddress == dataAddress)
     {
         if (MovePrevious() || FirstItem.DiskBuffer.DataAddress == CurrentItem.DiskBuffer.DataAddress)
         {
             LastItem.DiskBuffer.DataAddress = CurrentItem.DiskBuffer.DataAddress;
             CurrentItem.NextItemAddress     = -1;
             Sop.DataBlock db = WriteToBlock(CurrentItem, CurrentItem.DiskBuffer);
             DataBlockDriver.SetDiskBlock(this, db, false);
         }
         else
         {
             throw new InvalidOperationException("Can't go previous but First is not the only item.");
         }
     }
     else
     {
         LinkedItemOnDisk curr = CurrentItem;
         LinkedItemOnDisk prev = null, next = null;
         if (MoveTo(curr.PreviousItemAddress))
         {
             prev = CurrentItem;
         }
         if (MoveTo(curr.NextItemAddress))
         {
             next = CurrentItem;
         }
         if (prev != null && next != null)
         {
             prev.NextItemAddress     = curr.NextItemAddress;
             next.PreviousItemAddress = curr.PreviousItemAddress;
             Sop.DataBlock db = WriteToBlock(prev, prev.DiskBuffer);
             DataBlockDriver.SetDiskBlock(this, db, false);
             db = WriteToBlock(next, next.DiskBuffer);
             DataBlockDriver.SetDiskBlock(this, db, false);
         }
     }
     if (MruManager.Count > 0)
     {
         MruManager.Remove(dataAddress, true);
     }
     DataBlockDriver.Remove(this, currBlock);
 }