Class DynamicValue
Assembly: OpenSearch.Net.dll
Syntax
public class DynamicValue : DynamicObject, IDynamicMetaObjectProvider, IEquatable<DynamicValue>, IConvertible
Constructors
|
Edit this page
View Source
DynamicValue(object)
Declaration
public DynamicValue(object value)
Parameters
Type |
Name |
Description |
object |
value |
The value to store in the instance
|
Properties
|
Edit this page
View Source
HasValue
Gets a value indicating whether this instance has value.
Declaration
public bool HasValue { get; }
Property Value
Type |
Description |
bool |
true if this instance has value; otherwise, false .
|
|
Edit this page
View Source
this[int]
Declaration
public DynamicValue this[int i] { get; }
Parameters
Type |
Name |
Description |
int |
i |
|
Property Value
|
Edit this page
View Source
this[string]
Declaration
public DynamicValue this[string name] { get; }
Parameters
Type |
Name |
Description |
string |
name |
|
Property Value
|
Edit this page
View Source
NullValue
Declaration
public static DynamicValue NullValue { get; }
Property Value
|
Edit this page
View Source
Value
Declaration
public object Value { get; }
Property Value
Methods
|
Edit this page
View Source
Default<T>(T)
Returns a default value if Value is null
Declaration
public T Default<T>(T defaultValue = default)
Parameters
Type |
Name |
Description |
T |
defaultValue |
Optional parameter for default value, if not given it returns default of type T
|
Returns
Type |
Description |
T |
If value is not null, value is returned, else default value is returned
|
Type Parameters
Name |
Description |
T |
When no default value is supplied, required to supply the default type
|
|
Edit this page
View Source
Equals(DynamicValue)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(DynamicValue compareValue)
Parameters
Returns
Type |
Description |
bool |
true if the current object is equal to the compareValue parameter; otherwise, false .
|
|
Edit this page
View Source
Equals(object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object compareValue)
Parameters
Returns
Overrides
|
Edit this page
View Source
GetHashCode()
Serves as a hash function for a particular type.
Declaration
public override int GetHashCode()
Returns
Type |
Description |
int |
A hash code for the current instance.
|
Overrides
|
Edit this page
View Source
GetTypeCode()
Declaration
public TypeCode GetTypeCode()
Returns
Type |
Description |
TypeCode |
The enumerated constant that is the TypeCode of the class or value type that implements this interface.
|
|
Edit this page
View Source
Get<T>(string)
Declaration
public T Get<T>(string path)
Parameters
Type |
Name |
Description |
string |
path |
|
Returns
Type Parameters
|
Edit this page
View Source
SelfOrNew(object)
Declaration
public static DynamicValue SelfOrNew(object v)
Parameters
Type |
Name |
Description |
object |
v |
|
Returns
|
Edit this page
View Source
Converts the value of this instance to an equivalent Boolean value using the specified culture-specific formatting information.
Declaration
public bool ToBoolean(IFormatProvider provider)
Parameters
Returns
Type |
Description |
bool |
A Boolean value equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified culture-specific formatting information.
Declaration
public byte ToByte(IFormatProvider provider)
Parameters
Returns
Type |
Description |
byte |
An 8-bit unsigned integer equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent Unicode character using the specified culture-specific formatting information.
Declaration
public char ToChar(IFormatProvider provider)
Parameters
Returns
Type |
Description |
char |
A Unicode character equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent DateTime using the specified culture-specific formatting
information.
Declaration
public DateTime ToDateTime(IFormatProvider provider)
Parameters
Returns
Type |
Description |
DateTime |
A DateTime instance equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent decimal number using the specified culture-specific formatting
information.
Declaration
public decimal ToDecimal(IFormatProvider provider)
Parameters
Returns
Type |
Description |
decimal |
A decimal number equivalent to the value of this instance.
|
|
Edit this page
View Source
ToDictionary()
Returns the value as a dictionary if the current value represents an object.
Otherwise returns null.
Declaration
public IDictionary<string, DynamicValue> ToDictionary()
Returns
|
Edit this page
View Source
Converts the value of this instance to an equivalent double-precision floating-point number using the specified culture-specific formatting
information.
Declaration
public double ToDouble(IFormatProvider provider)
Parameters
Returns
Type |
Description |
double |
A double-precision floating-point number equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent 16-bit signed integer using the specified culture-specific formatting information.
Declaration
public short ToInt16(IFormatProvider provider)
Parameters
Returns
Type |
Description |
short |
An 16-bit signed integer equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent 32-bit signed integer using the specified culture-specific formatting information.
Declaration
public int ToInt32(IFormatProvider provider)
Parameters
Returns
Type |
Description |
int |
An 32-bit signed integer equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent 64-bit signed integer using the specified culture-specific formatting information.
Declaration
public long ToInt64(IFormatProvider provider)
Parameters
Returns
Type |
Description |
long |
An 64-bit signed integer equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture-specific formatting information.
Declaration
[CLSCompliant(false)]
public sbyte ToSByte(IFormatProvider provider)
Parameters
Returns
Type |
Description |
sbyte |
An 8-bit signed integer equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent single-precision floating-point number using the specified culture-specific formatting
information.
Declaration
public float ToSingle(IFormatProvider provider)
Parameters
Returns
Type |
Description |
float |
A single-precision floating-point number equivalent to the value of this instance.
|
|
Edit this page
View Source
ToString()
Declaration
public override string ToString()
Returns
Overrides
|
Edit this page
View Source
Converts the value of this instance to an equivalent string using the specified culture-specific formatting
information.
Declaration
public string ToString(IFormatProvider provider)
Parameters
Returns
Type |
Description |
string |
A string instance equivalent to the value of this instance.
|
|
Edit this page
View Source
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.
Declaration
public object ToType(Type conversionType, IFormatProvider provider)
Parameters
Type |
Name |
Description |
Type |
conversionType |
The Type to which the value of this instance is converted.
|
IFormatProvider |
provider |
An IFormatProvider interface implementation that supplies culture-specific formatting
information.
|
Returns
Type |
Description |
object |
An object instance of type conversionType whose value is equivalent to the value of this
instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified culture-specific formatting information.
Declaration
[CLSCompliant(false)]
public ushort ToUInt16(IFormatProvider provider)
Parameters
Returns
Type |
Description |
ushort |
An 16-bit unsigned integer equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified culture-specific formatting information.
Declaration
[CLSCompliant(false)]
public uint ToUInt32(IFormatProvider provider)
Parameters
Returns
Type |
Description |
uint |
An 32-bit unsigned integer equivalent to the value of this instance.
|
|
Edit this page
View Source
Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified culture-specific formatting information.
Declaration
[CLSCompliant(false)]
public ulong ToUInt64(IFormatProvider provider)
Parameters
Returns
Type |
Description |
ulong |
An 64-bit unsigned integer equivalent to the value of this instance.
|
|
Edit this page
View Source
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.
Declaration
public override bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result)
Parameters
Type |
Name |
Description |
BinaryOperationBinder |
binder |
Provides 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.
|
object |
arg |
The 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.
|
object |
result |
The result of the binary operation.
|
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.)
|
Overrides
|
Edit this page
View Source
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.
Declaration
public override bool TryConvert(ConvertBinder binder, out object result)
Parameters
Type |
Name |
Description |
ConvertBinder |
binder |
Provides 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.
|
object |
result |
The result of the type conversion operation.
|
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.)
|
Overrides
|
Edit this page
View Source
TryGetMember(GetMemberBinder, out object)
Declaration
public override bool TryGetMember(GetMemberBinder binder, out object result)
Parameters
Returns
Overrides
|
Edit this page
View Source
TryParse<T>(T)
Attempts to convert the value to type of T, failing to do so will return the defaultValue.
Declaration
public T TryParse<T>(T defaultValue = default)
Parameters
Type |
Name |
Description |
T |
defaultValue |
Optional parameter for default value, if not given it returns default of type T
|
Returns
Type |
Description |
T |
If value is not null, value is returned, else default value is returned
|
Type Parameters
Name |
Description |
T |
When no default value is supplied, required to supply the default type
|
Operators
|
Edit this page
View Source
operator ==(DynamicValue, object)
Declaration
public static bool operator ==(DynamicValue dynamicValue, object compareValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator bool(DynamicValue)
Declaration
public static implicit operator bool(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator DateTime(DynamicValue)
Declaration
public static implicit operator DateTime(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator decimal(DynamicValue)
Declaration
public static implicit operator decimal(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator double(DynamicValue)
Declaration
public static implicit operator double(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator Guid(DynamicValue)
Declaration
public static implicit operator Guid(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator int(DynamicValue)
Declaration
public static implicit operator int(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator long(DynamicValue)
Declaration
public static implicit operator long(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator float(DynamicValue)
Declaration
public static implicit operator float(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator string(DynamicValue)
Declaration
public static implicit operator string(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
implicit operator TimeSpan(DynamicValue)
Declaration
public static implicit operator TimeSpan(DynamicValue dynamicValue)
Parameters
Returns
|
Edit this page
View Source
operator !=(DynamicValue, object)
Declaration
public static bool operator !=(DynamicValue dynamicValue, object compareValue)
Parameters
Returns
Implements
Extension Methods