1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2025-04-10 11:15:45 +02:00

Added object base version of TryRemove API

This commit is contained in:
Sergio Pedri 2020-06-24 17:19:56 +02:00
parent 449d1547ab
commit 98a706bbf5
3 changed files with 16 additions and 7 deletions
Microsoft.Toolkit.Mvvm/Messaging/Microsoft.Collections.Extensions

View File

@ -139,6 +139,12 @@ public bool TryGetValue(TKey key, out TValue? value)
return false;
}
/// <inheritdoc/>
object? IDictionarySlim<TKey>.TryRemove(TKey key, out bool success)
{
return TryRemove(key, out success);
}
/// <inheritdoc/>
public TValue? TryRemove(TKey key, out bool success)
{

View File

@ -24,12 +24,7 @@ internal interface IDictionarySlim<in TKey, out TValue> : IDictionarySlim<TKey>
/// <exception cref="ArgumentException">Thrown if the key wasn't present.</exception>
TValue this[TKey key] { get; }
/// <summary>
/// Tries to remove a value with a specified key.
/// </summary>
/// <param name="key">The key of the value to remove.</param>
/// <param name="success">Whether or not the key was present.</param>
/// <returns>The removed value, if it was present.</returns>
TValue? TryRemove(TKey key, out bool success);
/// <inheritdoc cref="IDictionarySlim{TKey}.TryRemove(TKey,out bool)"/>
new TValue? TryRemove(TKey key, out bool success);
}
}

View File

@ -18,6 +18,14 @@ internal interface IDictionarySlim<in TKey>
/// </summary>
int Count { get; }
/// <summary>
/// Tries to remove a value with a specified key.
/// </summary>
/// <param name="key">The key of the value to remove.</param>
/// <param name="success">Whether or not the key was present.</param>
/// <returns>The removed value, if it was present.</returns>
object? TryRemove(TKey key, out bool success);
/// <summary>
/// Removes an item from the dictionary with the specified key, if present.
/// </summary>