Pip-Services-Commons-Dotnet
Public Member Functions | Static Public Member Functions | List of all members
PipServices3.Commons.Data.AnyValueArray Class Reference

Cross-language implementation of dynamic object array what can hold values of any type. The stored values can be converted to different types using variety of accessor methods. More...

Inheritance diagram for PipServices3.Commons.Data.AnyValueArray:
PipServices3.Commons.Data.ICloneable

Public Member Functions

 AnyValueArray ()
 Creates a new instance of the array. More...
 
 AnyValueArray (object[] values)
 Creates a new instance of the array and assigns its value. More...
 
 AnyValueArray (IEnumerable values)
 Creates a new instance of the array and assigns its value. More...
 
virtual object Get (int index)
 Gets an array element specified by its index. More...
 
virtual void Set (int index, object value)
 Sets a new value into array element specified by its index. More...
 
object GetAsObject ()
 Gets the value stored in this array element without any conversions More...
 
void SetAsObject (object value)
 Sets a new value for this array element More...
 
void Append (object[] values)
 Appends new elements to this array. More...
 
void Append (IEnumerable values)
 Appends new elements to this array. More...
 
object GetAsObject (int index)
 Gets an array element specified by its index. More...
 
void SetAsObject (int index, object value)
 Sets a new value into array element specified by its index. More...
 
string GetAsNullableString (int index)
 Converts array element into a string or returns null if conversion is not possible. More...
 
string GetAsString (int index)
 Converts array element into a string or returns "" if conversion is not possible. More...
 
string GetAsStringWithDefault (int index, string defaultValue)
 Converts array element into a string or returns default value if conversion is not possible. More...
 
bool GetAsNullableBoolean (int index)
 Converts array element into a boolean or returns null if conversion is not possible. More...
 
bool GetAsBoolean (int index)
 Converts array element into a boolean or returns false if conversion is not possible. More...
 
bool GetAsBooleanWithDefault (int index, bool defaultValue)
 Converts array element into a boolean or returns default value if conversion is not possible. More...
 
int GetAsNullableInteger (int index)
 Converts array element into an integer or returns null if conversion is not possible. More...
 
int GetAsInteger (int index)
 Converts array element into an integer or returns 0 if conversion is not possible. More...
 
int GetAsIntegerWithDefault (int index, int defaultValue)
 Converts array element into an integer or returns default value if conversion is not possible. More...
 
long GetAsNullableLong (int index)
 Converts array element into a long or returns null if conversion is not possible. More...
 
long GetAsLong (int index)
 Converts array element into a long or returns 0 if conversion is not possible. More...
 
long GetAsLongWithDefault (int index, long defaultValue)
 Converts array element into a long or returns default value if conversion is not possible. More...
 
float GetAsNullableFloat (int index)
 Converts array element into a float or returns null if conversion is not possible. More...
 
float GetAsFloat (int index)
 Converts array element into a float or returns 0 if conversion is not possible. More...
 
float GetAsFloatWithDefault (int index, float defaultValue)
 Converts array element into a float or returns default value if conversion is not possible. More...
 
double GetAsNullableDouble (int index)
 Converts array element into a double or returns null if conversion is not possible. More...
 
double GetAsDouble (int index)
 Converts array element into a double or returns 0 if conversion is not possible. More...
 
double GetAsDoubleWithDefault (int index, double defaultValue)
 Converts array element into a double or returns default value if conversion is not possible. More...
 
DateTime GetAsNullableDateTime (int index)
 Converts array element into a Date or returns null if conversion is not possible. More...
 
DateTime GetAsDateTime (int index)
 Converts array element into a Date or returns current date if conversion is not possible. More...
 
DateTime GetAsDateTimeWithDefault (int index, DateTime? defaultValue)
 Converts array element into a Date or returns default value if conversion is not possible. More...
 
TimeSpan GetAsNullableTimeSpan (int index)
 
TimeSpan GetAsTimeSpan (int index)
 
TimeSpan GetAsTimeSpanWithDefault (int index, TimeSpan? defaultValue)
 
GetAsNullableEnum< T > (int index)
 
GetAsEnum< T > (int index)
 
GetAsEnumWithDefault< T > (int index, T defaultValue)
 
GetATypes< T > (int index)
 Converts array element into a value defined by specied typecode. If conversion is not possible it returns default value for the specified type.. More...
 
GetAsNullableType< T > (int index)
 Converts array element into a value defined by specied typecode. If conversion is not possible it returns null. More...
 
GetAsNullableTypeWithDefault< T > (int index, T defaultValue)
 Converts array element into a value defined by specied typecode. If conversion is not possible it returns default value. More...
 
AnyValue GetAsValue (int index)
 Converts array element into an AnyValue or returns an empty AnyValue if conversion is not possible. More...
 
AnyValueArray GetAsNullableArray (int index)
 Converts array element into an AnyValueArray or returns null if conversion is not possible. More...
 
AnyValueArray GetAsArray (int index)
 Converts array element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible. More...
 
AnyValueArray GetAsArrayWithDefault (int index, AnyValueArray defaultValue)
 Converts array element into an AnyValueArray or returns default value if conversion is not possible. More...
 
AnyValueMap GetAsNullableMap (int index)
 Converts array element into an AnyValueMap or returns null if conversion is not possible. More...
 
AnyValueMap GetAsMap (int index)
 Converts array element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible. More...
 
AnyValueMap GetAsMapWithDefault (int index, AnyValueMap defaultValue)
 Converts array element into an AnyValueMap or returns default value if conversion is not possible. More...
 
new bool Contains (object value)
 Checks if this array contains a value. The check uses direct comparison between elements and the specified value. More...
 
bool ContainsAs< T > (object value)
 Checks if this array contains a value. The check before comparison converts elements and the value to type specified by type code. More...
 
override string ToString ()
 Gets a string representation of the object. The result is a comma-separated list of string representations of individual elements as "value1,value2,value3" More...
 
object Clone ()
 Creates a binary clone of this object. More...
 

Static Public Member Functions

static AnyValueArray FromValues (params object[] values)
 Creates a new AnyValueArray from a list of values More...
 
static AnyValueArray FromValue (object value)
 Converts specified value into AnyValueArray. More...
 
static AnyValueArray FromString (string value, char separator, bool removeDuplicates)
 Splits specified string into elements using a separator and assigns the elements to a newly created AnyValueArray. More...
 
static AnyValueArray FromString (string value, char separator)
 Splits specified string into elements using a separator and assigns the elements to a newly created AnyValueArray. More...
 

Detailed Description

Cross-language implementation of dynamic object array what can hold values of any type. The stored values can be converted to different types using variety of accessor methods.

var value1 = new AnyValueArray(new object[]{1, "123.456", "2018-01-01"});
value1.GetAsBoolean(0); // Result: true
value1.GetAsInteger(1); // Result: 123
value1.GetAsFloat(1); // Result: 123.456
value1.GetAsDateTime(2); // Result: new Date(2018,0,1)

See StringConverter, BooleanConverter, IntegerConverter, LongConverter, DoubleConverter, FloatConverter, DateTimeConverter, ICloneable

Constructor & Destructor Documentation

◆ AnyValueArray() [1/3]

PipServices3.Commons.Data.AnyValueArray.AnyValueArray ( )

Creates a new instance of the array.

◆ AnyValueArray() [2/3]

PipServices3.Commons.Data.AnyValueArray.AnyValueArray ( object []  values)

Creates a new instance of the array and assigns its value.

Parameters
values(optional) values to initialize this array.

◆ AnyValueArray() [3/3]

PipServices3.Commons.Data.AnyValueArray.AnyValueArray ( IEnumerable  values)

Creates a new instance of the array and assigns its value.

Parameters
values(optional) values to initialize this array.

Member Function Documentation

◆ Append() [1/2]

void PipServices3.Commons.Data.AnyValueArray.Append ( object []  values)

Appends new elements to this array.

Parameters
valuesa list of elements to be added.

◆ Append() [2/2]

void PipServices3.Commons.Data.AnyValueArray.Append ( IEnumerable  values)

Appends new elements to this array.

Parameters
valuesa list of elements to be added.

◆ Clone()

object PipServices3.Commons.Data.AnyValueArray.Clone ( )

Creates a binary clone of this object.

Returns
a clone of this object.

Implements PipServices3.Commons.Data.ICloneable.

◆ Contains()

new bool PipServices3.Commons.Data.AnyValueArray.Contains ( object  value)

Checks if this array contains a value. The check uses direct comparison between elements and the specified value.

Parameters
valuea value to be checked
Returns
true if this array contains the value or false otherwise.

◆ ContainsAs< T >()

bool PipServices3.Commons.Data.AnyValueArray.ContainsAs< T > ( object  value)

Checks if this array contains a value. The check before comparison converts elements and the value to type specified by type code.

Template Parameters
Tthe class type
Parameters
valuea value to be checked
Returns
true if this array contains the value or false otherwise.

See TypeConverter.ToType<T>(object)

◆ FromString() [1/2]

static AnyValueArray PipServices3.Commons.Data.AnyValueArray.FromString ( string  value,
char  separator,
bool  removeDuplicates 
)
static

Splits specified string into elements using a separator and assigns the elements to a newly created AnyValueArray.

Parameters
valuea string value to be split and assigned to AnyValueArray
separatora separator to split the string
removeDuplicates(optional) true to remove duplicated elements
Returns
a newly created AnyValueArray.

◆ FromString() [2/2]

static AnyValueArray PipServices3.Commons.Data.AnyValueArray.FromString ( string  value,
char  separator 
)
static

Splits specified string into elements using a separator and assigns the elements to a newly created AnyValueArray.

Parameters
valuea string value to be split and assigned to AnyValueArray
separatora separator to split the string
Returns
a newly created AnyValueArray.

◆ FromValue()

static AnyValueArray PipServices3.Commons.Data.AnyValueArray.FromValue ( object  value)
static

Converts specified value into AnyValueArray.

Parameters
valuevalue to be converted
Returns
a newly created AnyValueArray.

See ArrayConverter.ToNullableArray(object)

◆ FromValues()

static AnyValueArray PipServices3.Commons.Data.AnyValueArray.FromValues ( params object []  values)
static

Creates a new AnyValueArray from a list of values

Parameters
valuesa list of values to initialize the created AnyValueArray
Returns
a newly created AnyValueArray.

◆ Get()

virtual object PipServices3.Commons.Data.AnyValueArray.Get ( int  index)
virtual

Gets an array element specified by its index.

Parameters
indexan index of the element to get.
Returns
the value of the array element.

◆ GetAsArray()

AnyValueArray PipServices3.Commons.Data.AnyValueArray.GetAsArray ( int  index)

Converts array element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.

Parameters
indexan index of element to get.
Returns
AnyValueArray value of the element or empty AnyValueArray if conversion is not supported.

◆ GetAsArrayWithDefault()

AnyValueArray PipServices3.Commons.Data.AnyValueArray.GetAsArrayWithDefault ( int  index,
AnyValueArray  defaultValue 
)

Converts array element into an AnyValueArray or returns default value if conversion is not possible.

Parameters
indexan index of element to get.
defaultValuethe default value
Returns
AnyValueArray value of the element or default value if conversion is not supported.

◆ GetAsBoolean()

bool PipServices3.Commons.Data.AnyValueArray.GetAsBoolean ( int  index)

Converts array element into a boolean or returns false if conversion is not possible.

Parameters
indexan index of element to get.
Returns
boolean value of the element or false if conversion is not supported.

See GetAsBooleanWithDefault(int, bool)

◆ GetAsBooleanWithDefault()

bool PipServices3.Commons.Data.AnyValueArray.GetAsBooleanWithDefault ( int  index,
bool  defaultValue 
)

Converts array element into a boolean or returns default value if conversion is not possible.

Parameters
indexan index of element to get.
defaultValuethe default value
Returns
boolean of the element or default value if conversion is not supported.

See BooleanConverter.ToBooleanWithDefault(object, bool)

◆ GetAsDateTime()

DateTime PipServices3.Commons.Data.AnyValueArray.GetAsDateTime ( int  index)

Converts array element into a Date or returns current date if conversion is not possible.

Parameters
indexan index of element to get.
Returns
DateTime value of element or current date if conversion is not supported.

See GetAsDateTimeWithDefault(int, DateTime?)

◆ GetAsDateTimeWithDefault()

DateTime PipServices3.Commons.Data.AnyValueArray.GetAsDateTimeWithDefault ( int  index,
DateTime?  defaultValue 
)

Converts array element into a Date or returns default value if conversion is not possible.

Parameters
indexan index of element to get.
defaultValuethe default value
Returns
DateTime value of element or default value if conversion is not supported.

See DateTimeConverter.ToDateTimeWithDefault(object, DateTime?)

◆ GetAsDouble()

double PipServices3.Commons.Data.AnyValueArray.GetAsDouble ( int  index)

Converts array element into a double or returns 0 if conversion is not possible.

Parameters
indexan index of element to get.
Returns
double value of element or 0 if conversion is not supported.

See GetAsDoubleWithDefault(int, double)

◆ GetAsDoubleWithDefault()

double PipServices3.Commons.Data.AnyValueArray.GetAsDoubleWithDefault ( int  index,
double  defaultValue 
)

Converts array element into a double or returns default value if conversion is not possible.

Parameters
indexan index of element to get.
defaultValuethe default value
Returns
double value of element or default value if conversion is not supported.

See DoubleConverter.ToDoubleWithDefault(object, double)

◆ GetAsFloat()

float PipServices3.Commons.Data.AnyValueArray.GetAsFloat ( int  index)

Converts array element into a float or returns 0 if conversion is not possible.

Parameters
indexan index of element to get.
Returns
float value of element or 0 if conversion is not supported.

See GetAsFloatWithDefault(int, float)

◆ GetAsFloatWithDefault()

float PipServices3.Commons.Data.AnyValueArray.GetAsFloatWithDefault ( int  index,
float  defaultValue 
)

Converts array element into a float or returns default value if conversion is not possible.

Parameters
indexan index of element to get.
defaultValuethe default value
Returns
float value of element or default value if conversion is not supported.

See FloatConverter.ToFloatWithDefault(object, float)

◆ GetAsInteger()

int PipServices3.Commons.Data.AnyValueArray.GetAsInteger ( int  index)

Converts array element into an integer or returns 0 if conversion is not possible.

Parameters
indexan index of element to get.
Returns
integer value of element or 0 if conversion is not supported.

See GetAsIntegerWithDefault(int, int)

◆ GetAsIntegerWithDefault()

int PipServices3.Commons.Data.AnyValueArray.GetAsIntegerWithDefault ( int  index,
int  defaultValue 
)

Converts array element into an integer or returns default value if conversion is not possible.

Parameters
indexan index of element to get.
defaultValuethe default value
Returns
integer value of element or default value if conversion is not supported.

See IntegerConverter.ToIntegerWithDefault(object, int)

◆ GetAsLong()

long PipServices3.Commons.Data.AnyValueArray.GetAsLong ( int  index)

Converts array element into a long or returns 0 if conversion is not possible.

Parameters
indexan index of element to get.
Returns
long value of element or 0 if conversion is not supported.

See GetAsLongWithDefault(int, long)

◆ GetAsLongWithDefault()

long PipServices3.Commons.Data.AnyValueArray.GetAsLongWithDefault ( int  index,
long  defaultValue 
)

Converts array element into a long or returns default value if conversion is not possible.

Parameters
indexan index of element to get.
defaultValuethe default value
Returns
long value of element or default value if conversion is not supported.

See LongConverter.ToLongWithDefault(object, long)

◆ GetAsMap()

AnyValueMap PipServices3.Commons.Data.AnyValueArray.GetAsMap ( int  index)

Converts array element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.

Parameters
indexan index of element to get.
Returns
AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.

See AnyValueMap

◆ GetAsMapWithDefault()

AnyValueMap PipServices3.Commons.Data.AnyValueArray.GetAsMapWithDefault ( int  index,
AnyValueMap  defaultValue 
)

Converts array element into an AnyValueMap or returns default value if conversion is not possible.

Parameters
indexan index of element to get.
defaultValuethe default value
Returns
nyValueMap value of the element or default value if conversion is not supported

See GetAsNullableMap(int)

◆ GetAsNullableArray()

AnyValueArray PipServices3.Commons.Data.AnyValueArray.GetAsNullableArray ( int  index)

Converts array element into an AnyValueArray or returns null if conversion is not possible.

Parameters
indexan index of element to get.
Returns
AnyValueArray value of the element or null if conversion is not supported.

◆ GetAsNullableBoolean()

bool PipServices3.Commons.Data.AnyValueArray.GetAsNullableBoolean ( int  index)

Converts array element into a boolean or returns null if conversion is not possible.

Parameters
indexan index of element to get.
Returns
boolean of the element or null if conversion is not supported.

See BooleanConverter.ToNullableBoolean(object)

◆ GetAsNullableDateTime()

DateTime PipServices3.Commons.Data.AnyValueArray.GetAsNullableDateTime ( int  index)

Converts array element into a Date or returns null if conversion is not possible.

Parameters
indexan index of element to get.
Returns
DateTime value of element or null if conversion is not supported.

See DateTimeConverter.ToNullableDateTime(object)

◆ GetAsNullableDouble()

double PipServices3.Commons.Data.AnyValueArray.GetAsNullableDouble ( int  index)

Converts array element into a double or returns null if conversion is not possible.

Parameters
indexan index of element to get.
Returns
double value of element or null if conversion is not supported.

See DoubleConverter.ToNullableDouble(object)

◆ GetAsNullableFloat()

float PipServices3.Commons.Data.AnyValueArray.GetAsNullableFloat ( int  index)

Converts array element into a float or returns null if conversion is not possible.

Parameters
indexan index of element to get.
Returns
float value of element or null if conversion is not supported.

See FloatConverter.ToNullableFloat(object)

◆ GetAsNullableInteger()

int PipServices3.Commons.Data.AnyValueArray.GetAsNullableInteger ( int  index)

Converts array element into an integer or returns null if conversion is not possible.

Parameters
indexan index of element to get.
Returns
integer value of element or null if conversion is not supported.

See IntegerConverter.ToNullableInteger(object)

◆ GetAsNullableLong()

long PipServices3.Commons.Data.AnyValueArray.GetAsNullableLong ( int  index)

Converts array element into a long or returns null if conversion is not possible.

Parameters
indexan index of element to get.
Returns
long value of element or null if conversion is not supported.

See LongConverter.ToNullableLong(object)

◆ GetAsNullableMap()

AnyValueMap PipServices3.Commons.Data.AnyValueArray.GetAsNullableMap ( int  index)

Converts array element into an AnyValueMap or returns null if conversion is not possible.

Parameters
indexan index of element to get.
Returns
AnyValueMap value of the element or null if conversion is not supported.

See AnyValueMap

◆ GetAsNullableString()

string PipServices3.Commons.Data.AnyValueArray.GetAsNullableString ( int  index)

Converts array element into a string or returns null if conversion is not possible.

Parameters
indexan index of element to get.
Returns
string value of the element or null if conversion is not supported.

See StringConverter.ToNullableString(object)

◆ GetAsNullableType< T >()

T PipServices3.Commons.Data.AnyValueArray.GetAsNullableType< T > ( int  index)

Converts array element into a value defined by specied typecode. If conversion is not possible it returns null.

Template Parameters
Tthe class type
Parameters
indexan index of element to get.
Returns
value of element defined by the typecode or null if conversion is not supported.

See TypeConverter.ToNullableType<T>(object)

Type Constraints
T :struct 

◆ GetAsNullableTypeWithDefault< T >()

T PipServices3.Commons.Data.AnyValueArray.GetAsNullableTypeWithDefault< T > ( int  index,
defaultValue 
)

Converts array element into a value defined by specied typecode. If conversion is not possible it returns default value.

Template Parameters
Tthe class type
Parameters
indexan index of element to get.
defaultValuethe default value
Returns
value of element defined by the typecode or default value if conversion is not supported.

See TypeConverter.ToTypeWithDefault<T>(object, T)

◆ GetAsObject() [1/2]

object PipServices3.Commons.Data.AnyValueArray.GetAsObject ( )

Gets the value stored in this array element without any conversions

Returns
the value of the array element.

◆ GetAsObject() [2/2]

object PipServices3.Commons.Data.AnyValueArray.GetAsObject ( int  index)

Gets an array element specified by its index.

Parameters
indexan index of the element to get.
Returns
the value of the array element.

◆ GetAsString()

string PipServices3.Commons.Data.AnyValueArray.GetAsString ( int  index)

Converts array element into a string or returns "" if conversion is not possible.

Parameters
indexan index of element to get.
Returns
string value of the element or "" if conversion is not supported.

See GetAsStringWithDefault(int, string)

◆ GetAsStringWithDefault()

string PipServices3.Commons.Data.AnyValueArray.GetAsStringWithDefault ( int  index,
string  defaultValue 
)

Converts array element into a string or returns default value if conversion is not possible.

Parameters
indexan index of element to get.
defaultValuethe default value
Returns
string value of the element or default value if conversion is not supported.

See StringConverter.ToStringWithDefault(object, string)

◆ GetAsValue()

AnyValue PipServices3.Commons.Data.AnyValueArray.GetAsValue ( int  index)

Converts array element into an AnyValue or returns an empty AnyValue if conversion is not possible.

Parameters
indexan index of element to get.
Returns
AnyValue value of the element or empty AnyValue if conversion is not supported.

See AnyValue, AnyValue.AnyValue(object)

◆ GetATypes< T >()

T PipServices3.Commons.Data.AnyValueArray.GetATypes< T > ( int  index)

Converts array element into a value defined by specied typecode. If conversion is not possible it returns default value for the specified type..

Template Parameters
Tthe class type
Parameters
indexan index of element to get.
Returns
value of element defined by the typecode or default value for the specified type. if conversion is not supported.

See TypeConverter.ToType<T>(object)

◆ Set()

virtual void PipServices3.Commons.Data.AnyValueArray.Set ( int  index,
object  value 
)
virtual

Sets a new value into array element specified by its index.

Parameters
indexan index of the element to put.
valuea new value for array element.

◆ SetAsObject() [1/2]

void PipServices3.Commons.Data.AnyValueArray.SetAsObject ( object  value)

Sets a new value for this array element

Parameters
valuethe new object value.

◆ SetAsObject() [2/2]

void PipServices3.Commons.Data.AnyValueArray.SetAsObject ( int  index,
object  value 
)

Sets a new value into array element specified by its index.

Parameters
indexan index of the element to put.
valuea new value for array element.

◆ ToString()

override string PipServices3.Commons.Data.AnyValueArray.ToString ( )

Gets a string representation of the object. The result is a comma-separated list of string representations of individual elements as "value1,value2,value3"

Returns
a string representation of the object.

See StringConverter.ToString(object)


The documentation for this class was generated from the following file: