wasSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 16  →  ?path2? @ 17
/Collections/Utilities/Extensions.cs
@@ -30,5 +30,28 @@
.SequenceEqual((dictionary ?? new Dictionary<TKey, TValue>())
.OrderBy(kvp => kvp.Key));
}
 
public static void AddOrReplace<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value)
{
switch (dictionary.ContainsKey(key))
{
case true:
dictionary[key] = value;
break;
default:
dictionary.Add(key, value);
break;
}
}
 
public static void AddIfNotExists<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value)
{
switch (!dictionary.ContainsKey(key))
{
case true:
dictionary.Add(key, value);
break;
}
}
}
}