public static CDictionary <TKey, TValue> Synchronized(CDictionary <TKey, TValue> dictionary) { if (dictionary == null) { throw new ArgumentNullException("dictionary"); } return(new SyncDictionary <TKey, TValue>(dictionary)); }
/// <summary> /// 初始化SyncDictionary对象实例 /// </summary> /// <param name="info"><see cref="System.Runtime.Serialization.SerializationInfo"></see>对象包含序列化<see cref="System.Collections.Generic.Dictionary{TKey, TValue}"></see>的必要信息。</param> /// <param name="context">A <see cref="System.Runtime.Serialization.StreamingContext"></see> 含有与序列化流<see cref="System.Collections.Generic.Dictionary{TKey, TValue}"></see>的源和目标的结构。</param> internal SyncDictionary(SerializationInfo info, StreamingContext context) : base(info, context) { this.dictionary = (CDictionary <TKey, TValue>)info.GetValue("ParentTable", typeof(CDictionary <TKey, TValue>)); if (this.dictionary == null) { throw new SerializationException("Insufficient state to return the real object."); } }
/// <summary> /// 初始化OrderedDictionary类的新实例 /// </summary> /// <param name="capacity">字典元素容量</param> /// <param name="comparer">比较器对象</param> public OrderedDictionary(int capacity, IEqualityComparer <TKey> comparer) { dictionary = new CDictionary <TKey, TValue>(capacity, comparer); list = new CList <KeyValuePair <TKey, TValue> >(); }
/// <summary> /// 初始化OrderedDictionary类的新实例 /// </summary> /// <param name="capacity">字典元素容量</param> public OrderedDictionary(int capacity) { dictionary = new CDictionary <TKey, TValue>(capacity); list = new CList <KeyValuePair <TKey, TValue> >(); }
/// <summary> /// 初始化OrderedDictionary类的新实例 /// </summary> /// <summary>初始化OrderedDictionary类的新实例,实例为空并具有默认的初始容量,使用默认的相等比较器等。</summary> public OrderedDictionary() { dictionary = new CDictionary <TKey, TValue>(); list = new CList <KeyValuePair <TKey, TValue> >(); }
/// <summary> /// 初始化SyncDictionary对象实例 /// </summary> /// <param name="dictionary">字典对象</param> public SyncDictionary(CDictionary <TKey, TValue> dictionary) { this.dictionary = dictionary; }