mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 01:03:01 +08:00
Initial commit.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user