Src/Newtonsoft.Json/Utilities/DictionaryWrapper.cs
(开头部分) 8KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Threading;
namespace Newtonsoft.Json.Utilities
{
internal interface IWrappedDictionary : IDictionary
{
object UnderlyingDictionary { get; }
}
internal class DictionaryWrapper<TKey, TValue> : IDictionary<TKey, TValue>, IWrappedDictionary
{
private readonly IDictionary _dictionary;
private readonly IDictionary<TKey, TValue> _genericDictionary;
private object _syncRoot;
public DictionaryWrapper(IDictionary dictionary)
{
ValidationUtils.ArgumentNotNull(dictionary, "dictionary");
_dictionary = dictionary;
}
public DictionaryWrapper(IDictionary<TKey, TValue> dictionary)
{
ValidationUtils.ArgumentNotNull(dictionary, "dictionary");
_genericDictionary = dictionary;
}
public void Add(TKey key, TValue value)
{
if (_genericDictionary != null)
_genericDictionary.Add(key, value);
else
_dictionary.Add(key, value);
}
public bool ContainsKey(TKey key)
{
if (_genericDictionary != null)
return _genericDictionary.ContainsKey(key);
else
return _dictionary.Contains(key);
}
public ICollection<TKey> Keys
{
get
{
if (_genericDictionary != null)
return _genericDictionary.Keys;
else
return _dictionary.Keys.Cast<TKey>().ToList();
}
}
后面还有 340 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
