Class DictionaryToken
A dictionary object is an associative table containing pairs of objects, known as the dictionary's entries. The key must be a NameToken and the value may be an kind of IToken.
public class DictionaryToken : IDataToken<IReadOnlyDictionary<string, IToken>>, IToken, IEquatable<IToken>, IEquatable<DictionaryToken>
- Inheritance
-
DictionaryToken
- Implements
- Inherited Members
Constructors
DictionaryToken(IReadOnlyDictionary<NameToken, IToken>)
Create a new DictionaryToken.
public DictionaryToken(IReadOnlyDictionary<NameToken, IToken> data)
Parameters
data
IReadOnlyDictionary<NameToken, IToken>The data this dictionary will contain.
Properties
Data
The key value pairs in this dictionary.
public IReadOnlyDictionary<string, IToken> Data { get; }
Property Value
Methods
ContainsKey(NameToken)
Whether the dictionary contains an entry with this name.
public bool ContainsKey(NameToken name)
Parameters
name
NameTokenThe name to check.
Returns
Equals(DictionaryToken)
public bool Equals(DictionaryToken other)
Parameters
other
DictionaryToken
Returns
Equals(IToken)
public bool Equals(IToken obj)
Parameters
obj
IToken
Returns
ToString()
public override string ToString()
Returns
TryGet(NameToken, out IToken)
Try and get the entry with a given name.
public bool TryGet(NameToken name, out IToken token)
Parameters
Returns
TryGet<T>(NameToken, out T)
Try and get the entry with a given name and a specific data type.
public bool TryGet<T>(NameToken name, out T token) where T : IToken
Parameters
name
NameTokenThe name of the entry to retrieve.
token
TThe token, if it is found.
Returns
Type Parameters
T
The expected data type of the dictionary value.
With(IReadOnlyDictionary<string, IToken>)
Create a new DictionaryToken.
public static DictionaryToken With(IReadOnlyDictionary<string, IToken> data)
Parameters
data
IReadOnlyDictionary<string, IToken>The data this dictionary will contain.
Returns
With(string, IToken)
Create a copy of this dictionary with the additional entry (or override the value of the existing entry).
public DictionaryToken With(string key, IToken value)
Parameters
key
stringThe key of the entry to create or override.
value
ITokenThe value of the entry to create or override.
Returns
- DictionaryToken
A new DictionaryToken with the entry created or modified.
With(NameToken, IToken)
Create a copy of this dictionary with the additional entry (or override the value of the existing entry).
public DictionaryToken With(NameToken key, IToken value)
Parameters
key
NameTokenThe key of the entry to create or override.
value
ITokenThe value of the entry to create or override.
Returns
- DictionaryToken
A new DictionaryToken with the entry created or modified.
Without(string)
Creates a copy of this dictionary with the entry with the specified key removed (if it exists).
public DictionaryToken Without(string key)
Parameters
key
stringThe key of the entry to remove.
Returns
- DictionaryToken
A new DictionaryToken with the entry removed.
Without(NameToken)
Creates a copy of this dictionary with the entry with the specified key removed (if it exists).
public DictionaryToken Without(NameToken key)
Parameters
key
NameTokenThe key of the entry to remove.
Returns
- DictionaryToken
A new DictionaryToken with the entry removed.