Class DynamicDictionary
A dictionary that supports dynamic access.
Implements
Inherited Members
Namespace: OpenSearch.Net
Assembly: OpenSearch.Net.dll
Syntax
public class DynamicDictionary : DynamicObject, IDynamicMetaObjectProvider, IEquatable<DynamicDictionary>, IEnumerable<string>, IDictionary<string, DynamicValue>, ICollection<KeyValuePair<string, DynamicValue>>, IEnumerable<KeyValuePair<string, DynamicValue>>, IEnumerable
Properties
| Edit this page View SourceCount
Gets the number of elements contained in the DynamicDictionary.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int | The number of elements contained in the DynamicDictionary. |
Empty
Returns an empty dynamic dictionary.
Declaration
public static DynamicDictionary Empty { get; }
Property Value
| Type | Description |
|---|---|
| DynamicDictionary | A DynamicDictionary instance. |
IsReadOnly
Gets a value indicating whether the DynamicDictionary is read-only.
Declaration
public bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| bool | Always returns false. |
this[string]
Gets or sets the DynamicValue with the specified name.
Declaration
public DynamicValue this[string name] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| string | name |
Property Value
| Type | Description |
|---|---|
| DynamicValue | A DynamicValue instance containing a value. |
Keys
Gets an ICollection<T> containing the keys of the DynamicDictionary.
Declaration
public ICollection<string> Keys { get; }
Property Value
| Type | Description |
|---|---|
| ICollection<string> | An ICollection<T> containing the keys of the DynamicDictionary. |
Values
Gets an ICollection<T> containing the values in the DynamicDictionary.
Declaration
public ICollection<DynamicValue> Values { get; }
Property Value
| Type | Description |
|---|---|
| ICollection<DynamicValue> | An ICollection<T> containing the values in the DynamicDictionary. |
Methods
| Edit this page View SourceAdd(KeyValuePair<string, DynamicValue>)
Adds an item to the DynamicDictionary.
Declaration
public void Add(KeyValuePair<string, DynamicValue> item)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyValuePair<string, DynamicValue> | item | The object to add to the DynamicDictionary. |
Add(string, DynamicValue)
Adds an element with the provided key and value to the DynamicDictionary.
Declaration
public void Add(string key, DynamicValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The object to use as the key of the element to add. |
| DynamicValue | value | The object to use as the value of the element to add. |
Clear()
Removes all items from the DynamicDictionary.
Declaration
public void Clear()
Contains(KeyValuePair<string, DynamicValue>)
Determines whether the DynamicDictionary contains a specific value.
Declaration
public bool Contains(KeyValuePair<string, DynamicValue> item)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyValuePair<string, DynamicValue> | item | The object to locate in the DynamicDictionary. |
Returns
| Type | Description |
|---|---|
| bool | true if |
ContainsKey(string)
Determines whether the DynamicDictionary contains an element with the specified key.
Declaration
public bool ContainsKey(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key to locate in the DynamicDictionary. |
Returns
| Type | Description |
|---|---|
| bool | true if the DynamicDictionary contains an element with the key; otherwise, false. |
CopyTo(KeyValuePair<string, DynamicValue>[], int)
Copies the elements of the DynamicDictionary to an Array, starting at a particular Array index.
Declaration
public void CopyTo(KeyValuePair<string, DynamicValue>[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyValuePair<string, DynamicValue>[] | array | The one-dimensional Array that is the destination of the elements copied from the DynamicDictionary. The Array must have zero-based indexing. |
| int | arrayIndex | The zero-based index in |
Create(IDictionary<string, object>)
Creates a dynamic dictionary from an IDictionary<TKey, TValue> instance.
Declaration
public static DynamicDictionary Create(IDictionary<string, object> values)
Parameters
| Type | Name | Description |
|---|---|---|
| IDictionary<string, object> | values | An IDictionary<TKey, TValue> instance, that the dynamic dictionary should be created from. |
Returns
| Type | Description |
|---|---|
| DynamicDictionary | An DynamicDictionary instance. |
Equals(DynamicDictionary)
Indicates whether the current DynamicDictionary is equal to another object of the same type.
Declaration
public bool Equals(DynamicDictionary other)
Parameters
| Type | Name | Description |
|---|---|---|
| DynamicDictionary | other | An DynamicDictionary instance to compare with this instance. |
Returns
| Type | Description |
|---|---|
| bool | true if the current instance is equal to the |
Equals(object)
Determines whether the specified object is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with this instance. |
Returns
| Type | Description |
|---|---|
| bool | true if the specified object is equal to this instance; otherwise, false. |
Overrides
| Edit this page View SourceGetDynamicMemberNames()
Returns the enumeration of all dynamic member names.
Declaration
public override IEnumerable<string> GetDynamicMemberNames()
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | A IEnumerable<T> that contains dynamic member names. |
Overrides
| Edit this page View SourceGetEnumerator()
Returns the enumeration of all dynamic member names.
Declaration
public IEnumerator<string> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<string> | A IEnumerable<T> that contains dynamic member names. |
GetHashCode()
Returns a hash code for this DynamicDictionary.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code for this DynamicDictionary, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
| Edit this page View SourceGetKeyValues()
Backwards compatible access to all the KeyValue pairs, in the next release you will be able to foreach directly
Declaration
public IEnumerable<KeyValuePair<string, DynamicValue>> GetKeyValues()
Returns
| Type | Description |
|---|---|
| IEnumerable<KeyValuePair<string, DynamicValue>> |
Get<T>(string)
Traverses data using path notation.
e.g some.deep.nested.json.path
A special lookup is available for ANY key _arbitrary_key_ e.g some.deep._arbitrary_key_.json.path which will traverse into the first key
If _arbitrary_key_ is the last value it will return the key name
Declaration
public T Get<T>(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | path into the stored object, keys are separated with a dot and the last key is returned as T |
Returns
| Type | Description |
|---|---|
| T | T or default |
Type Parameters
| Name | Description |
|---|---|
| T |
Remove(KeyValuePair<string, DynamicValue>)
Removes the first occurrence of a specific object from the DynamicDictionary.
Declaration
public bool Remove(KeyValuePair<string, DynamicValue> item)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyValuePair<string, DynamicValue> | item | The object to remove from the DynamicDictionary. |
Returns
| Type | Description |
|---|---|
| bool | true if |
Remove(string)
Removes the element with the specified key from the DynamicDictionary.
Declaration
public bool Remove(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key of the element to remove. |
Returns
| Type | Description |
|---|---|
| bool | true if the element is successfully removed; otherwise, false. |
ToDictionary()
Creates a new instance of Dictionary{String,Object} using the keys and underlying object values of this DynamicDictionary instance's key values.
Declaration
public Dictionary<string, object> ToDictionary()
Returns
| Type | Description |
|---|---|
| Dictionary<string, object> |
TryGetMember(GetMemberBinder, out object)
Provides the implementation for operations that get member values. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as getting a value for a property.
Declaration
public override bool TryGetMember(GetMemberBinder binder, out object result)
Parameters
| Type | Name | Description |
|---|---|---|
| GetMemberBinder | binder | Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the DynamicObject class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. |
| object | result | The result of the get operation. For example, if the method is called for a property, you can assign the property
value to |
Returns
| Type | Description |
|---|---|
| bool | true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.) |
Overrides
| Edit this page View SourceTryGetValue(string, out DynamicValue)
Gets the value associated with the specified key.
Declaration
public bool TryGetValue(string key, out DynamicValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key whose value to get. |
| DynamicValue | value | When this method returns, the value associated with the specified key, if the key is found; otherwise, the default
value for the type of the |
Returns
| Type | Description |
|---|---|
| bool | true if the DynamicDictionary contains an element with the specified key; otherwise, false. |
TrySetMember(SetMemberBinder, object)
Provides the implementation for operations that set member values. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as setting a value for a property.
Declaration
public override bool TrySetMember(SetMemberBinder binder, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| SetMemberBinder | binder | Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member to which the value is being assigned. For example, for the statement sampleObject.SampleProperty = "Test", where sampleObject is an instance of the class derived from the DynamicObject class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive. |
| object | value | The value to set to the member. For example, for sampleObject.SampleProperty = "Test", where sampleObject is an
instance of the class derived from the DynamicObject class, the |
Returns
| Type | Description |
|---|---|
| bool | true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.) |