1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-22 22:16:13 -04:00
Files
Sonarr/src/NzbDrone.Common/Exceptron/fastJSON/SafeDictionary.cs
T
2016-12-21 20:38:37 -08:00

31 lines
812 B
C#

//http://fastjson.codeplex.com/
//http://fastjson.codeplex.com/license
using System.Collections.Generic;
namespace NzbDrone.Common.Exceptron.fastJSON
{
internal class SafeDictionary<TKey, TValue>
{
private readonly object _Padlock = new object();
private readonly Dictionary<TKey, TValue> _Dictionary = new Dictionary<TKey, TValue>();
internal bool TryGetValue(TKey key, out TValue value)
{
return _Dictionary.TryGetValue(key, out value);
}
internal TValue this[TKey key] => _Dictionary[key];
internal void Add(TKey key, TValue value)
{
lock (_Padlock)
{
if (_Dictionary.ContainsKey(key) == false)
_Dictionary.Add(key, value);
}
}
}
}