Class FsWatcherDictionary<T, U>
- Assembly
- SunamoFileSystem.dll
Thread-safe dictionary wrapper for file system watcher operations that prevents duplicate key additions.
public class FsWatcherDictionary<T, U> : IDictionary<T, U>, ICollection<KeyValuePair<T, U>>, IEnumerable<KeyValuePair<T, U>>, IEnumerable where T : notnull
Type Parameters
TThe type of keys in the dictionary.
UThe type of values in the dictionary.
- Inheritance
-
FsWatcherDictionary<T, U>
- Implements
-
IDictionary<T, U>ICollection<KeyValuePair<T, U>>IEnumerable<KeyValuePair<T, U>>
- Inherited Members
- Extension Methods
Properties
Count
Gets the number of key/value pairs in the dictionary.
public int Count { get; }
Property Value
IsReadOnly
Gets a value indicating whether the dictionary is read-only. Always returns false.
public bool IsReadOnly { get; }
Property Value
this[T]
Gets or sets the value associated with the specified key. Returns default if the key does not exist.
public U this[T key] { get; set; }
Parameters
keyTThe key of the value to get or set.
Property Value
- U
The value associated with the specified key, or default if not found.
Keys
Gets a collection containing the keys of the dictionary.
public ICollection<T> Keys { get; }
Property Value
- ICollection<T>
Values
Gets a collection containing the values of the dictionary.
public ICollection<U> Values { get; }
Property Value
- ICollection<U>
Methods
Add(KeyValuePair<T, U>)
Adds the specified key/value pair to the dictionary.
public void Add(KeyValuePair<T, U> item)
Parameters
itemKeyValuePair<T, U>The key/value pair to add.
Add(T, U)
Adds the specified key and value to the dictionary in a thread-safe manner. If the key already exists, the value is not updated.
public void Add(T key, U value)
Parameters
keyTThe key of the element to add.
valueUThe value of the element to add.
Clear()
Removes all keys and values from the dictionary.
public void Clear()
Contains(KeyValuePair<T, U>)
Determines whether the dictionary contains the specified key/value pair.
public bool Contains(KeyValuePair<T, U> item)
Parameters
itemKeyValuePair<T, U>The key/value pair to locate.
Returns
- bool
True if the key/value pair is found; otherwise, false.
ContainsKey(T)
Determines whether the dictionary contains the specified key.
public bool ContainsKey(T key)
Parameters
keyTThe key to locate.
Returns
- bool
True if the dictionary contains the key; otherwise, false.
CopyTo(KeyValuePair<T, U>[], int)
Copies the dictionary elements to an array. Not implemented.
public void CopyTo(KeyValuePair<T, U>[] array, int arrayIndex)
Parameters
arrayKeyValuePair<T, U>[]The destination array.
arrayIndexintThe zero-based index at which copying begins.
GetEnumerator()
Returns an enumerator that iterates through the dictionary.
public IEnumerator<KeyValuePair<T, U>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<T, U>>
An enumerator for the dictionary.
Remove(KeyValuePair<T, U>)
Removes the specified key/value pair from the dictionary.
public bool Remove(KeyValuePair<T, U> item)
Parameters
itemKeyValuePair<T, U>The key/value pair to remove.
Returns
- bool
True if the element was successfully removed; otherwise, false.
Remove(T)
Removes the value with the specified key from the dictionary.
public bool Remove(T key)
Parameters
keyTThe key of the element to remove.
Returns
- bool
True if the element was successfully removed; otherwise, false.
TryGetValue(T, out U)
Gets the value associated with the specified key.
public bool TryGetValue(T key, out U value)
Parameters
keyTThe key of the value to get.
valueUWhen this method returns, contains the value associated with the specified key, if found.
Returns
- bool
True if the dictionary contains an element with the specified key; otherwise, false.