-Added .NET 2.0 support

-Documentation
This commit is contained in:
JamesNK
2009-08-01 12:06:21 +00:00
parent 5611228772
commit ff5c48660d
30 changed files with 788 additions and 119 deletions
@@ -580,13 +580,31 @@ namespace Newtonsoft.Json.Utilities
public static bool AddDistinct<T>(this IList<T> list, T value, IEqualityComparer<T> comparer)
{
if (list.Contains(value, comparer))
if (list.ContainsValue(value, comparer))
return false;
list.Add(value);
return true;
}
// this is here because LINQ Bridge doesn't support Contains with IEqualityComparer<T>
public static bool ContainsValue<TSource>(this IEnumerable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
{
if (comparer == null)
comparer = EqualityComparer<TSource>.Default;
if (source == null)
throw new ArgumentNullException("source");
foreach (TSource local in source)
{
if (comparer.Equals(local, value))
return true;
}
return false;
}
public static bool AddRangeDistinct<T>(this IList<T> list, IEnumerable<T> values)
{
return list.AddRangeDistinct(values, EqualityComparer<T>.Default);