Interface IConfigurationDictionary<TElement>
Represents a dictionary of values stored in a property, keyed against a string value. Use the interface for properties representing an arbitrary number of the same kind of object identified by unique string keys.
Inherited Members
Namespace: OpenCollar.Extensions.Configuration
Assembly: OpenCollar.Extensions.Configuration.dll
Syntax
public interface IConfigurationDictionary<TElement> : IDictionary<string, TElement>, ICollection<KeyValuePair<string, TElement>>, IEnumerable<KeyValuePair<string, TElement>>, IEnumerable, INotifyCollectionChanged, IConfigurationObject, IDisposable, INotifyPropertyChanged
Type Parameters
Name | Description |
---|---|
TElement | The type of the dictionary element. This must be nullable if the type is a reference type and can be null. |
Remarks
The following UML has been generated directly from the source code using Jebbs PlantUML .
Examples
In the example below a property on an interface is defined as containing an arbitray number of strings.
IConfigurationDictionary<string> Names
{
get; set;
}
If the configuration is specified in a JSON configuration file it would look something like this:
{
"Names": {
"First": "Value 1",
"Second": "Value 2",
"Third": "Value 3"
}
}
Methods
| Improve this Doc View SourceAddCopy(String, TElement)
Adds a new value with the key specified, copying the properties and elements from the value give, returning the new value.
Declaration
TElement AddCopy(string key, TElement value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key identifying the value to add. |
TElement | value | The value to copy. |
Returns
Type | Description |
---|---|
TElement | The newly added element. If this element is derived from IConfigurationObject, IConfigurationCollection<TElement> or IConfigurationDictionary<TElement>, and the object given was not created by this library, then a new object will be created and they properties and elements in the object given will be copied. |
Remarks
Used to add objects and collections that have been constructed externally using alternate implementations.
AddNew(String)
Adds a new value with the key specified, returning the new value.
Declaration
TElement AddNew(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key identifying the value to add. |
Returns
Type | Description |
---|---|
TElement |
Remarks
This allows instances of the internal implementation of objects to be created and added to the collection, and returned to be populated.
Contains(TElement)
Determines whether this dictionary contains the element specified.
Declaration
bool Contains(TElement element)
Parameters
Type | Name | Description |
---|---|---|
TElement | element | The element for which to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if the dictionary contains the specified element; otherwise, false. |