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 Dynamic
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int | The number of elements contained in the Dynamic |
Empty
Returns an empty dynamic dictionary.
Declaration
public static DynamicDictionary Empty { get; }
Property Value
Type | Description |
---|---|
Dynamic |
A Dynamic |
IsReadOnly
Gets a value indicating whether the Dynamic
Declaration
public bool IsReadOnly { get; }
Property Value
| Edit this page View Sourcethis[string]
Gets or sets the Dynamic
Declaration
public DynamicValue this[string name] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
string | name |
Property Value
Type | Description |
---|---|
Dynamic |
A Dynamic |
Keys
Gets an ICollection<T> containing the keys of the Dynamic
Declaration
public ICollection<string> Keys { get; }
Property Value
Type | Description |
---|---|
ICollection<string> | An ICollection<T> containing the keys of the Dynamic |
Values
Gets an ICollection<T> containing the values in the Dynamic
Declaration
public ICollection<DynamicValue> Values { get; }
Property Value
Type | Description |
---|---|
ICollection<Dynamic |
An ICollection<T> containing the values in the Dynamic |
Methods
| Edit this page View SourceAdd(KeyValuePair<string, DynamicValue>)
Adds an item to the Dynamic
Declaration
public void Add(KeyValuePair<string, DynamicValue> item)
Parameters
Type | Name | Description |
---|---|---|
Key |
item | The object to add to the Dynamic |
Add(string, DynamicValue)
Adds an element with the provided key and value to the Dynamic
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. |
Dynamic |
value | The object to use as the value of the element to add. |
Clear()
Removes all items from the Dynamic
Declaration
public void Clear()
Contains(KeyValuePair<string, DynamicValue>)
Determines whether the Dynamic
Declaration
public bool Contains(KeyValuePair<string, DynamicValue> item)
Parameters
Type | Name | Description |
---|---|---|
Key |
item | The object to locate in the Dynamic |
Returns
Type | Description |
---|---|
bool | true if |
ContainsKey(string)
Determines whether the Dynamic
Declaration
public bool ContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key to locate in the Dynamic |
Returns
Type | Description |
---|---|
bool | true if the Dynamic |
CopyTo(KeyValuePair<string, DynamicValue>[], int)
Copies the elements of the Dynamic
Declaration
public void CopyTo(KeyValuePair<string, DynamicValue>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
Key |
array | The one-dimensional Array that is the destination of the elements copied from the
Dynamic |
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 |
---|---|
Dynamic |
An Dynamic |
Equals(DynamicDictionary)
Indicates whether the current Dynamic
Declaration
public bool Equals(DynamicDictionary other)
Parameters
Type | Name | Description |
---|---|---|
Dynamic |
other | An Dynamic |
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
Returns
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 Dynamic
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for this Dynamic |
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<Key |
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 Dynamic
Declaration
public bool Remove(KeyValuePair<string, DynamicValue> item)
Parameters
Type | Name | Description |
---|---|---|
Key |
item | The object to remove from the Dynamic |
Returns
Type | Description |
---|---|
bool | true if |
Remove(string)
Removes the element with the specified key from the Dynamic
Declaration
public bool Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the element to remove. |
Returns
| Edit this page View SourceToDictionary()
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 Dynamic
Declaration
public override bool TryGetMember(GetMemberBinder binder, out object result)
Parameters
Type | Name | Description |
---|---|---|
Get |
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 Dynamic |
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. |
Dynamic |
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 Dynamic |
TrySetMember(SetMemberBinder, object)
Provides the implementation for operations that set member values. Classes derived from the Dynamic
Declaration
public override bool TrySetMember(SetMemberBinder binder, object value)
Parameters
Type | Name | Description |
---|---|---|
Set |
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 Dynamic |
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 Dynamic |
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.) |