Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public fields | Properties | Public Member Functions | List of all members
Loyc.Collections.TypeDictionaryWithBaseTypeLookups< Value > Class Template Reference

A dictionary whose keys are Type objects. This dictionary behaves almost identically to a standard dictionary, except that the TryGetValue method will find matches on base types and interfaces, e.g. if you add a dictionary entry for IEnumerable, then TryGetValue(typeof(BitArray), out _) will return true. More...


Source file:
Inheritance diagram for Loyc.Collections.TypeDictionaryWithBaseTypeLookups< Value >:
Loyc.Collections.IDictionaryAndReadOnly< K, V > Loyc.Collections.IAdd< in T > Loyc.Collections.IIndexed< in K, out V > Loyc.Collections.ICollectionAndReadOnly< T >

Remarks

A dictionary whose keys are Type objects. This dictionary behaves almost identically to a standard dictionary, except that the TryGetValue method will find matches on base types and interfaces, e.g. if you add a dictionary entry for IEnumerable, then TryGetValue(typeof(BitArray), out _) will return true.

This class is not thread-safe.

This class is keeps a cache of types you've searched for with TryGetValue so it can respond to repeated queries for the same type more quickly. For example, if you add a dictionary entry for IEnumerable and search for typeof(BitArray), a new cache entry is added for BitArray that holds the value associated with IEnumerable.

Whenever you modify the dictionary, the cache is cleared.

Public fields

int Count => _dict.Count
 
bool IsReadOnly => false
 
IEnumerable< Type > Keys => _dict.Keys
 
IEnumerable< Value > Values => _dict.Values
 

Properties

Value this[Type key] [get, set]
 
- Properties inherited from Loyc.Collections.IIndexed< in K, out V >
this[K key] [get]
 Gets the value associated with the specified key. More...
 

Public Member Functions

 TypeDictionaryWithBaseTypeLookups (IDictionary< Type, Value > copy)
 
bool ContainsKey (Type key)
 
IEnumerator< KeyValuePair
< Type, Value > > 
GetEnumerator ()
 
bool Contains (KeyValuePair< Type, Value > item)
 
void CopyTo (KeyValuePair< Type, Value >[] array, int arrayIndex)
 
void Add (KeyValuePair< Type, Value > item)
 
void Add (Type key, Value value)
 
bool Remove (Type key)
 
bool Remove (KeyValuePair< Type, Value > item)
 
void Clear ()
 
bool TryGetValue (Type type, [MaybeNullWhen(false)] out Value value)
 
- Public Member Functions inherited from Loyc.Collections.IAdd< in T >
void Add (T item)