Class ElasticsearchDynamicValue
- Namespace
- Elasticsearch.Net
- Assembly
- Elasticsearch.Net.dll
public class ElasticsearchDynamicValue : DynamicObject, IDynamicMetaObjectProvider, IEquatable<ElasticsearchDynamicValue>, IConvertible
- Inheritance
-
ElasticsearchDynamicValue
- Implements
- Inherited Members
Constructors
ElasticsearchDynamicValue(object)
Initializes a new instance of the ElasticsearchDynamicValue class.
public ElasticsearchDynamicValue(object value)
Parameters
value
objectThe value to store in the instance
Properties
HasValue
Gets a value indicating whether this instance has value.
public bool HasValue { get; }
Property Value
- bool
true
if this instance has value; otherwise,false
.
Remarks
null is considered as not being a value.
this[int]
public ElasticsearchDynamicValue this[int i] { get; }
Parameters
i
int
Property Value
this[string]
public ElasticsearchDynamicValue this[string name] { get; }
Parameters
name
string
Property Value
Value
Gets the inner value
public object Value { get; }
Property Value
Methods
Default<T>(T)
Returns a default value if Value is null
public T Default<T>(T defaultValue = default)
Parameters
defaultValue
TOptional parameter for default value, if not given it returns default of type T
Returns
- T
If value is not null, value is returned, else default value is returned
Type Parameters
T
When no default value is supplied, required to supply the default type
Equals(ElasticsearchDynamicValue)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(ElasticsearchDynamicValue compareValue)
Parameters
compareValue
ElasticsearchDynamicValueAn ElasticsearchDynamicValue to compare with this instance.
Returns
- bool
true
if the current object is equal to thecompareValue
parameter; otherwise,false
.
Equals(object)
public override bool Equals(object compareValue)
Parameters
compareValue
objectThe object to compare with the current ElasticsearchDynamicValue.
Returns
- bool
true
if the specified object is equal to the current ElasticsearchDynamicValue; otherwise,false
.
GetHashCode()
Serves as a hash function for a particular type.
public override int GetHashCode()
Returns
- int
A hash code for the current instance.
GetTypeCode()
Returns the TypeCode for this instance.
public TypeCode GetTypeCode()
Returns
- TypeCode
The enumerated constant that is the TypeCode of the class or value type that implements this interface.
ToBoolean(IFormatProvider)
Converts the value of this instance to an equivalent Boolean value using the specified culture-specific formatting information.
public bool ToBoolean(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- bool
A Boolean value equivalent to the value of this instance.
ToByte(IFormatProvider)
Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified culture-specific formatting information.
public byte ToByte(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- byte
An 8-bit unsigned integer equivalent to the value of this instance.
ToChar(IFormatProvider)
Converts the value of this instance to an equivalent Unicode character using the specified culture-specific formatting information.
public char ToChar(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- char
A Unicode character equivalent to the value of this instance.
ToDateTime(IFormatProvider)
Converts the value of this instance to an equivalent DateTime using the specified culture-specific formatting information.
public DateTime ToDateTime(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
ToDecimal(IFormatProvider)
Converts the value of this instance to an equivalent decimal number using the specified culture-specific formatting information.
public decimal ToDecimal(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
ToDouble(IFormatProvider)
Converts the value of this instance to an equivalent double-precision floating-point number using the specified culture-specific formatting information.
public double ToDouble(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- double
A double-precision floating-point number equivalent to the value of this instance.
ToInt16(IFormatProvider)
Converts the value of this instance to an equivalent 16-bit signed integer using the specified culture-specific formatting information.
public short ToInt16(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- short
An 16-bit signed integer equivalent to the value of this instance.
ToInt32(IFormatProvider)
Converts the value of this instance to an equivalent 32-bit signed integer using the specified culture-specific formatting information.
public int ToInt32(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- int
An 32-bit signed integer equivalent to the value of this instance.
ToInt64(IFormatProvider)
Converts the value of this instance to an equivalent 64-bit signed integer using the specified culture-specific formatting information.
public long ToInt64(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- long
An 64-bit signed integer equivalent to the value of this instance.
ToSByte(IFormatProvider)
Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture-specific formatting information.
[CLSCompliant(false)]
public sbyte ToSByte(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- sbyte
An 8-bit signed integer equivalent to the value of this instance.
ToSingle(IFormatProvider)
Converts the value of this instance to an equivalent single-precision floating-point number using the specified culture-specific formatting information.
public float ToSingle(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- float
A single-precision floating-point number equivalent to the value of this instance.
ToString()
public override string ToString()
Returns
ToString(IFormatProvider)
Converts the value of this instance to an equivalent string using the specified culture-specific formatting information.
public string ToString(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
ToType(Type, IFormatProvider)
Converts the value of this instance to an object of the specified Type that has an equivalent value, using the specified culture-specific formatting information.
public object ToType(Type conversionType, IFormatProvider provider)
Parameters
conversionType
TypeThe Type to which the value of this instance is converted.
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- object
An object instance of type
conversionType
whose value is equivalent to the value of this instance.
ToUInt16(IFormatProvider)
Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified culture-specific formatting information.
[CLSCompliant(false)]
public ushort ToUInt16(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- ushort
An 16-bit unsigned integer equivalent to the value of this instance.
ToUInt32(IFormatProvider)
Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified culture-specific formatting information.
[CLSCompliant(false)]
public uint ToUInt32(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- uint
An 32-bit unsigned integer equivalent to the value of this instance.
ToUInt64(IFormatProvider)
Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified culture-specific formatting information.
[CLSCompliant(false)]
public ulong ToUInt64(IFormatProvider provider)
Parameters
provider
IFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- ulong
An 64-bit unsigned integer equivalent to the value of this instance.
TryBinaryOperation(BinaryOperationBinder, object, out object)
Provides implementation for binary operations. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as addition and multiplication.
public override bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result)
Parameters
binder
BinaryOperationBinderProvides information about the binary operation. The binder.Operation property returns an ExpressionType object. For example, for the sum = first + second statement, where first and second are derived from the DynamicObject class, binder.Operation returns ExpressionType.Add.
arg
objectThe right operand for the binary operation. For example, for the sum = first + second statement, where first and second are derived from the DynamicObject class,
arg
is equal to second.result
objectThe result of the binary operation.
Returns
- bool
true
if the operation is successful; otherwise,false
. If this method returnsfalse
, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
TryConvert(ConvertBinder, out object)
Provides implementation for type conversion operations. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations that convert an object from one type to another.
public override bool TryConvert(ConvertBinder binder, out object result)
Parameters
binder
ConvertBinderProvides information about the conversion operation. The binder.Type property provides the type to which the object must be converted. For example, for the statement (String)sampleObject in C# (CType(sampleObject, Type) in Visual Basic), where sampleObject is an instance of the class derived from the DynamicObject class, binder.Type returns the string type. The binder.Explicit property provides information about the kind of conversion that occurs. It returns true for explicit conversion and false for implicit conversion.
result
objectThe result of the type conversion operation.
Returns
- bool
true
if the operation is successful; otherwise,false
. If this method returnsfalse
, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
TryGetMember(GetMemberBinder, out object)
public override bool TryGetMember(GetMemberBinder binder, out object result)
Parameters
binder
GetMemberBinderresult
object
Returns
TryParse<T>(T)
Attempts to convert the value to type of T, failing to do so will return the defaultValue.
public T TryParse<T>(T defaultValue = default)
Parameters
defaultValue
TOptional parameter for default value, if not given it returns default of type T
Returns
- T
If value is not null, value is returned, else default value is returned
Type Parameters
T
When no default value is supplied, required to supply the default type
Operators
operator ==(ElasticsearchDynamicValue, object)
public static bool operator ==(ElasticsearchDynamicValue dynamicValue, object compareValue)
Parameters
dynamicValue
ElasticsearchDynamicValuecompareValue
object
Returns
implicit operator bool(ElasticsearchDynamicValue)
public static implicit operator bool(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
implicit operator DateTime(ElasticsearchDynamicValue)
public static implicit operator DateTime(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
implicit operator decimal(ElasticsearchDynamicValue)
public static implicit operator decimal(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
implicit operator double(ElasticsearchDynamicValue)
public static implicit operator double(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
implicit operator Guid(ElasticsearchDynamicValue)
public static implicit operator Guid(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
implicit operator int(ElasticsearchDynamicValue)
public static implicit operator int(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
implicit operator long(ElasticsearchDynamicValue)
public static implicit operator long(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
implicit operator float(ElasticsearchDynamicValue)
public static implicit operator float(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
implicit operator string(ElasticsearchDynamicValue)
public static implicit operator string(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
implicit operator TimeSpan(ElasticsearchDynamicValue)
public static implicit operator TimeSpan(ElasticsearchDynamicValue dynamicValue)
Parameters
dynamicValue
ElasticsearchDynamicValue
Returns
operator !=(ElasticsearchDynamicValue, object)
public static bool operator !=(ElasticsearchDynamicValue dynamicValue, object compareValue)
Parameters
dynamicValue
ElasticsearchDynamicValuecompareValue
object