Esempio n. 1
0
 protected ProgressiveCollection(Progressor <T> progressor, ICollection <T> cache, IEqualityComparer <T> comparer)
 {
     _cache        = cache ?? throw new ArgumentNullException(nameof(cache));
     Cache         = Extensions.WrapAsIReadOnlyCollection(_cache);
     Progressor    = progressor ?? throw new ArgumentNullException(nameof(progressor));
     _subscription = Progressor.SubscribeAction(obj => _cache.Add(obj));
     Comparer      = comparer ?? EqualityComparer <T> .Default;
 }
Esempio n. 2
0
 public ExtendedDictionary(IEqualityComparer <TKey> keyComparer, IEqualityComparer <TValue> valueComparer)
 {
     _valueComparer = valueComparer ?? throw new ArgumentNullException(nameof(valueComparer));
     if (keyComparer == null)
     {
         throw new ArgumentNullException(nameof(keyComparer));
     }
     _wrapped = new Dictionary <TKey, TValue>(keyComparer);
     Keys     = Extensions.WrapAsIReadOnlyCollection(_wrapped.Keys);
     Values   = Extensions.WrapAsIReadOnlyCollection(_wrapped.Values);
 }
Esempio n. 3
0
 public ExtendedDictionary(IEnumerable <KeyValuePair <TKey, TValue> > prototype, IEqualityComparer <TKey> keyComparer, IEqualityComparer <TValue> valueComparer)
 {
     _valueComparer = valueComparer ?? throw new ArgumentNullException(nameof(valueComparer));
     if (keyComparer == null)
     {
         throw new ArgumentNullException(nameof(keyComparer));
     }
     _wrapped = new Dictionary <TKey, TValue>(keyComparer);
     Keys     = Extensions.WrapAsIReadOnlyCollection(_wrapped.Keys);
     Values   = Extensions.WrapAsIReadOnlyCollection(_wrapped.Values);
     if (prototype == null)
     {
         throw new ArgumentNullException(nameof(prototype));
     }
     this.AddRange(prototype);
 }