Forward equality comparer to dictionary
This commit is contained in:
parent
0fc595f8a5
commit
82ae67ab29
@ -13,17 +13,17 @@ namespace ObservableCollections
|
||||
readonly Dictionary<TKey, TValue> dictionary;
|
||||
public object SyncRoot { get; } = new object();
|
||||
|
||||
public ObservableDictionary()
|
||||
public ObservableDictionary(IEqualityComparer<TKey>? comparer = null)
|
||||
{
|
||||
this.dictionary = new Dictionary<TKey, TValue>();
|
||||
this.dictionary = new Dictionary<TKey, TValue>(comparer: comparer);
|
||||
}
|
||||
|
||||
public ObservableDictionary(IEnumerable<KeyValuePair<TKey, TValue>> collection)
|
||||
public ObservableDictionary(IEnumerable<KeyValuePair<TKey, TValue>> collection, IEqualityComparer<TKey>? comparer = null)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
this.dictionary = new Dictionary<TKey, TValue>(collection);
|
||||
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
|
||||
this.dictionary = new Dictionary<TKey, TValue>(collection: collection, comparer: comparer);
|
||||
#else
|
||||
this.dictionary = new Dictionary<TKey, TValue>();
|
||||
this.dictionary = new Dictionary<TKey, TValue>(comparer: comparer);
|
||||
foreach (var item in collection)
|
||||
{
|
||||
dictionary.Add(item.Key, item.Value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user