/// <summary> /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"></see>. /// </summary> /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"></see>.</param> /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"></see> is read-only.</exception> public override void Add(T item) { using (WriteLock.Acquire()) { if (!Contains(item)) { base.Add(item); } } }
/// <summary> /// Adds all of the items in the source. /// </summary> /// <param name="source">The source.</param> public void AddAll(IEnumerable <T> source) { List <T> tempList = new List <T>(); using (WriteLock.Acquire()) { foreach (T item in source) { if (!Contains(item)) { tempList.Add(item); } } if (tempList.Count != 0) { AddRange(tempList); } } }