public static void ClearAndAddRange <TValue>(this ICollection <KeyValuePair <string, TValue> > dictionary, XmlKeyTextValueListWrapper <TValue> collection) { if (collection.IsWrapperFor(dictionary)) // For efficiency { return; } var pairs = collection.ToList(); dictionary.Clear(); foreach (var item in pairs) { dictionary.Add(item); } }
public static void CopyTo <TValue>(this XmlKeyTextValueListWrapper <TValue> collection, ICollection <KeyValuePair <string, TValue> > dictionary) { if (dictionary == null) { throw new ArgumentNullException("dictionary"); } if (collection == null) { dictionary.Clear(); } else { if (collection.IsWrapperFor(dictionary)) // For efficiency { return; } var pairs = collection.ToList(); dictionary.Clear(); foreach (var item in pairs) { dictionary.Add(item); } } }