Table of Contents

Class DynamicBody

Namespace
Elasticsearch.Net
Assembly
Elasticsearch.Net.dll

A dictionary that supports dynamic access.

public class DynamicBody : DynamicObject, IDynamicMetaObjectProvider, IEquatable<DynamicBody>, IEnumerable<string>, IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
Inheritance
DynamicBody
Implements
Inherited Members

Constructors

DynamicBody()

public DynamicBody()

Properties

Count

Gets the number of elements contained in the DynamicBody.

public int Count { get; }

Property Value

int

The number of elements contained in the DynamicBody.

Empty

Returns an empty dynamic dictionary.

public static DynamicBody Empty { get; }

Property Value

DynamicBody

A DynamicBody instance.

IsReadOnly

Gets a value indicating whether the DynamicBody is read-only.

public bool IsReadOnly { get; }

Property Value

bool

Always returns false.

this[string]

Gets or sets the ElasticsearchDynamicValue with the specified name.

public dynamic this[string name] { get; set; }

Parameters

name string

Property Value

dynamic

A ElasticsearchDynamicValue instance containing a value.

Keys

Gets an ICollection<T> containing the keys of the DynamicBody.

public ICollection<string> Keys { get; }

Property Value

ICollection<string>

An ICollection<T> containing the keys of the DynamicBody.

Values

Gets an ICollection<T> containing the values in the DynamicBody.

public ICollection<dynamic> Values { get; }

Property Value

ICollection<dynamic>

An ICollection<T> containing the values in the DynamicBody.

Methods

Add(KeyValuePair<string, dynamic>)

Adds an item to the DynamicBody.

public void Add(KeyValuePair<string, dynamic> item)

Parameters

item KeyValuePair<string, dynamic>

The object to add to the DynamicBody.

Add(string, dynamic)

Adds an element with the provided key and value to the DynamicBody.

public void Add(string key, dynamic value)

Parameters

key string

The object to use as the key of the element to add.

value dynamic

The object to use as the value of the element to add.

Clear()

Removes all items from the DynamicBody.

public void Clear()

Contains(KeyValuePair<string, dynamic>)

Determines whether the DynamicBody contains a specific value.

public bool Contains(KeyValuePair<string, dynamic> item)

Parameters

item KeyValuePair<string, dynamic>

The object to locate in the DynamicBody.

Returns

bool

true if item is found in the DynamicBody; otherwise, false.

ContainsKey(string)

Determines whether the DynamicBody contains an element with the specified key.

public bool ContainsKey(string key)

Parameters

key string

The key to locate in the DynamicBody.

Returns

bool

true if the DynamicBody contains an element with the key; otherwise, false.

CopyTo(KeyValuePair<string, dynamic>[], int)

Copies the elements of the DynamicBody to an Array, starting at a particular Array index.

public void CopyTo(KeyValuePair<string, dynamic>[] array, int arrayIndex)

Parameters

array KeyValuePair<string, dynamic>[]

The one-dimensional Array that is the destination of the elements copied from the DynamicBody. The Array must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Create(IDictionary<string, object>)

Creates a dynamic dictionary from an IDictionary<TKey, TValue> instance.

public static DynamicBody Create(IDictionary<string, object> values)

Parameters

values IDictionary<string, object>

An IDictionary<TKey, TValue> instance, that the dynamic dictionary should be created from.

Returns

DynamicBody

An DynamicBody instance.

Equals(DynamicBody)

Indicates whether the current DynamicBody is equal to another object of the same type.

public bool Equals(DynamicBody other)

Parameters

other DynamicBody

An DynamicBody instance to compare with this instance.

Returns

bool

true if the current instance is equal to the other parameter; otherwise, false.

Equals(object)

Determines whether the specified object is equal to this instance.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

GetDynamicMemberNames()

Returns the enumeration of all dynamic member names.

public override IEnumerable<string> GetDynamicMemberNames()

Returns

IEnumerable<string>

A IEnumerable<T> that contains dynamic member names.

GetEnumerator()

Returns the enumeration of all dynamic member names.

public IEnumerator<string> GetEnumerator()

Returns

IEnumerator<string>

A IEnumerable<T> that contains dynamic member names.

GetHashCode()

Returns a hash code for this DynamicBody.

public override int GetHashCode()

Returns

int

A hash code for this DynamicBody, suitable for use in hashing algorithms and data structures like a hash table.

Remove(KeyValuePair<string, dynamic>)

Removes the first occurrence of a specific object from the DynamicBody.

public bool Remove(KeyValuePair<string, dynamic> item)

Parameters

item KeyValuePair<string, dynamic>

The object to remove from the DynamicBody.

Returns

bool

true if item was successfully removed from the DynamicBody; otherwise, false.

Remove(string)

Removes the element with the specified key from the DynamicBody.

public bool Remove(string key)

Parameters

key string

The key of the element to remove.

Returns

bool

true if the element is successfully removed; otherwise, false.

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.

public override bool TryGetMember(GetMemberBinder binder, out object result)

Parameters

binder GetMemberBinder

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.

result object

The result of the get operation. For example, if the method is called for a property, you can assign the property value to result.

Returns

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.)

TryGetValue(string, out dynamic)

Gets the value associated with the specified key.

public bool TryGetValue(string key, out dynamic value)

Parameters

key string

The key whose value to get.

value dynamic

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 value parameter. This parameter is passed uninitialized.

Returns

bool

true if the DynamicBody 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.

public override bool TrySetMember(SetMemberBinder binder, object value)

Parameters

binder SetMemberBinder

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.

value object

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 value is "Test".

Returns

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.)