public MruItem <TKey, TValue> RemoveInTail(bool moveToRemoveList) { if (_tail != null) { Count--; MruItem <TKey, TValue> d = _tail.Data; if (_tail.Previous != null) { _tail.Previous.Next = null; _tail = _tail.Previous; } else { _tail = null; _head = null; } if (d.Value is Sop.DataBlock) { //** check whether this needs to be supported.. //if (((DataBlock)d.Value).IsDirty) //{ // if (MoveToRemoveList && DataDriver != null && !RemovedObjects.ContainsKey(d.Value)) // RemovedObjects.Add(d.Value, d.Value); //} } else if (moveToRemoveList) { if (!RemovedObjects.ContainsKey(d.Key)) { if (d.Value is IInternalPersistent) { if (((IInternalPersistent)d.Value).IsDirty) { RemovedObjects.Add(d.Key, d.Value); } } else { RemovedObjects.Add(d.Key, d.Value); } } } return(d); } return(null); }
private void filtersToolStripMenuItem_Click(object sender, EventArgs e) { GenericArrayList <UserFilterObject> RemovedObjects; TabPage CurrTab; frmFilters FiltersDlg = new frmFilters(UserFilters); FiltersDlg.ShowDialog(); RemovedObjects = FiltersDlg.GetRemovedObjects(); if (RemovedObjects.Count > 0) { //perform real deleting operation foreach (UserFilterObject filter in RemovedObjects) { logcat.RemoveSlot(filter.Name); for (int i = 0; i < tbFilterContainer.TabPages.Count; i++) { CurrTab = tbFilterContainer.TabPages[i]; if (CurrTab.Text == filter.Name) { tbFilterContainer.TabPages.Remove(CurrTab); CurrTab.Dispose(); } } } RemovedObjects.Clear(); UserFilterObject.SaveFilters(UserFilters, "filter.flt"); } }
/* * /// <summary> * /// Based on MaxMemoryUsage vs. current usage, this function will generate OnMaxCapacity event * /// to cause associated CollectionOnDisk (DataStore) to offload objects onto Disk. * /// </summary> * protected void MonitorMemory() * { * System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess(); * long MemoryUsage = p.WorkingSet64; * IntPtr MaxMemoryUsage = p.MaxWorkingSet; * } */ /// <summary> /// Save Removed Blocks to target store /// </summary> public void SaveRemovedBlocks() { mruManager.SaveRemovedBlocks(); Recycle(RemovedObjects.Values); RemovedObjects.Clear(); }
/// <summary> /// Delete specified container and its sub containers/records from parent container in indexer object. /// If removing container does not exist in the parent container, it does nothing but returns null. /// </summary> /// <param name="containerID">Container id to be removed</param> /// <param name="parentContainerID">Parent container id which has removing container</param> /// <remarks>This function removes all child password records/containers in removing container</remarks> /// <returns>List of removed containers/records. It returns null if removing was not done successfully</returns> public override RemovedObjects RemoveAllContainers(int containerID, int parentContainerID) { // Check dest container exists if (!this.ContainerIndexes.ContainsKey(parentContainerID)) { return null; } RemovedObjects removedObj = new RemovedObjects(); // Remove all child password records ICollection<int> removingRecordCollection = this.GetChildRecords(containerID); if (removingRecordCollection != null) { // Since removingRecordCollection is a "Reference Type", values within the variable will be deleted at the same time original value is removed // Here copies actual value to new variable, which is independent to original reference int[] removingRecords = new int[removingRecordCollection.Count]; for (int i = 0; i < removingRecordCollection.Count; i++) { removingRecords[i] = removingRecordCollection.ElementAt(i); } // Remove records here for (int i = 0; i < removingRecords.Length; i++) { this.RemoveRecord(removingRecords[i]); removedObj.Removed[typeof(PasswordRecord)].Add(removingRecords[i]); } } // Remove all child containers ICollection<int> removingContainerCollection = this.GetChildContainers(containerID); if (removingContainerCollection != null) { // Since removingContainerCollection is a "Reference Type", values within the variable will be deleted at the same time original value is removed // Here copies actual value to new variable, which is independent to original reference int[] removingContainers = new int[removingContainerCollection.Count]; for (int i = 0; i < removingContainerCollection.Count; i++) { removingContainers[i] = removingContainerCollection.ElementAt(i); } for (int i = 0; i < removingContainers.Length; i++) { RemovedObjects removedChildren = this.RemoveAllContainers(removingContainers[i], containerID); // Recursive call removedObj.Removed[typeof(PasswordContainer)].Add(removingContainers[i]); // Add up removed sub container ids foreach (int removedContainerID in removedChildren.Removed[typeof(PasswordContainer)]) { removedObj.Removed[typeof(PasswordContainer)].Add(removedContainerID); } // Add up removed record ids in sub containers foreach (int removedRecordID in removedChildren.Removed[typeof(PasswordRecord)]) { removedObj.Removed[typeof(PasswordRecord)].Add(removedRecordID); } } } this.ContainerIndexes[parentContainerID].Remove(containerID); this.ContainerReverseIndexes.Remove(containerID); return removedObj; }