mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
22 lines
524 B
C#
22 lines
524 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace MQTTnet.Core
|
|
{
|
|
public static class DictionaryExtensions
|
|
{
|
|
public static TValue Take<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
|
|
{
|
|
if (dictionary == null) throw new ArgumentNullException(nameof(dictionary));
|
|
|
|
TValue value;
|
|
if (dictionary.TryGetValue(key, out value))
|
|
{
|
|
dictionary.Remove(key);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
}
|
|
}
|