Class MruManager
API that manages a MRU (Most Recently Used files) table which is stored in the AppSettings file.
Implements
Inherited Members
Namespace: BionicCode.Utilities.Net
Assembly: BionicCode.Utilities.Net.Wpf.dll
Syntax
public class MruManager : ViewModel, IMruManager, IViewModel, IProgressReporter, IViewModelCommon, INotifyDataErrorInfo, IProgressReporterCommon, INotifyPropertyChanged
Constructors
| Improve this Doc View SourceMruManager()
Default constructor
Declaration
public MruManager()
Properties
| Improve this Doc View SourceInternalMostRecentlyUsedFiles
The underlying collection that holds the MostRecentlyUsedFileItem elements.
This collection is the source for the public MostRecentlyUsedFiles property, which is a ReadOnlyObservableCollection<T>.
Declaration
protected ObservableCollection<MostRecentlyUsedFileItem> InternalMostRecentlyUsedFiles { get; }
Property Value
| Type | Description |
|---|---|
| ObservableCollection<MostRecentlyUsedFileItem> |
MaxMostRecentlyUsedCount
The maximum number of files that are kept in the MRU table.
The default value is 10.
Declaration
public int MaxMostRecentlyUsedCount { get; set; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Remarks
When the limit is exceeded, the least recent used file will be removed from the MRU table every time a new file is added.
The maximum allowed value is 100. The minimum allowed value is 1.
MostRecentlyUsedFile
Gets the MRU file which is the last file added to the MRU table.
Declaration
public MostRecentlyUsedFileItem MostRecentlyUsedFile { get; }
Property Value
| Type | Description |
|---|---|
| MostRecentlyUsedFileItem |
MostRecentlyUsedFiles
A ReadOnlyObservableCollection<T> collection of MostRecentlyUsedFileItem which contains the MRU files.
Declaration
public ReadOnlyObservableCollection<MostRecentlyUsedFileItem> MostRecentlyUsedFiles { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyObservableCollection<MostRecentlyUsedFileItem> |
Methods
| Improve this Doc View SourceAddMostRecentlyUsedFile(String)
Adds a file with the specified path to the MRU table.
Declaration
public void AddMostRecentlyUsedFile(string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| String | filePath | The path to the file which is to add to the MRU table. |
Remarks
Checks if the file exists. Does nothing if file doesn't exist. When the number of files in the MRU table exceeds the limit set by MaxMostRecentlyUsedCount the entry with the least recent access is removed from the table.
Clear()
Clears the MRU list.
Declaration
public void Clear()
IsMruCountValid(Int32)
Property validation delegate. Validates the MaxMostRecentlyUsedCount property values.
Declaration
protected virtual (bool IsValid, IEnumerable<object> ErrorMessages) IsMruCountValid(int count)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | count | The max count value for MaxMostRecentlyUsedCount to validate. |
Returns
| Type | Description |
|---|---|
| System.ValueTuple<Boolean, IEnumerable<Object>> |
OnFileAdded(MostRecentlyUsedFileItem, MostRecentlyUsedFileItem)
Called when the InternalMostRecentlyUsedFiles has changed.
Declaration
protected virtual void OnFileAdded(MostRecentlyUsedFileItem oldItem, MostRecentlyUsedFileItem newItem)
Parameters
| Type | Name | Description |
|---|---|---|
| MostRecentlyUsedFileItem | oldItem | The removed MostRecentlyUsedFileItem item. |
| MostRecentlyUsedFileItem | newItem | The newly added MostRecentlyUsedFileItem item. |
Events
| Improve this Doc View SourceFileAdded
Raised when a new file was added to the MRU list. The event args contains the old and the new MostRecentlyUsedFileItem.
Once the max MostRecentlyUsedFileItem limit is reached, the least used file will be removed from the list to make space for the new item.
In this case the OldValue is the removed oldest item in the list.
Otherwise OldValue will be null.
Declaration
public event EventHandler<ValueChangedEventArgs<MostRecentlyUsedFileItem>> FileAdded
Event Type
| Type | Description |
|---|---|
| EventHandler<ValueChangedEventArgs<MostRecentlyUsedFileItem>> |