Pip-Services-Commons-Dotnet
|
Cross-language implementation of a map (dictionary) where all keys and values are strings. The stored values can be converted to different types using variety of accessor methods. More...
Public Member Functions | |
StringValueMap () | |
Creates a new instance of the map and assigns its value. More... | |
StringValueMap (IDictionary< string, string > map) | |
Creates a new instance of the map and assigns its value. More... | |
StringValueMap (object value) | |
Creates a new instance of the map and assigns its value. More... | |
virtual string | Get (string key) |
Gets a map element specified by its key. More... | |
virtual void | Set (string key, string value) |
Sets a new value for this array element by its key More... | |
void | Append (IDictionary< string, object > map) |
Appends new elements to this map. More... | |
void | Append (IDictionary< string, string > map) |
Appends new elements to this map. More... | |
object | GetAsObject () |
Gets the value stored in this map element without any conversions More... | |
void | SetAsObject (object value) |
Sets a new value for this array element More... | |
void | SetAsObject (string key, object value) |
Sets a new value to map element specified by its index. When the index is not defined, it resets the entire map value.This method has double purpose because method overrides are not supported in JavaScript. More... | |
object | GetAsObject (string key) |
Gets the value stored in map element without any conversions. When element key is not defined it returns the entire map value. More... | |
string | GetAsNullableString (string key) |
Converts map element into a string or returns null if conversion is not possible. More... | |
string | GetAsString (string key) |
Converts map element into a string or returns "" if conversion is not possible. More... | |
string | GetAsStringWithDefault (string key, string defaultValue) |
Converts map element into a string or returns default value if conversion is not possible. More... | |
bool | GetAsNullableBoolean (string key) |
Converts map element into a boolean or returns null if conversion is not possible. More... | |
bool | GetAsBoolean (string key) |
Converts map element into a boolean or returns false if conversion is not possible. More... | |
bool | GetAsBooleanWithDefault (string key, bool defaultValue) |
Converts map element into a boolean or returns default value if conversion is not possible. More... | |
int | GetAsNullableInteger (string key) |
Converts map element into an integer or returns null if conversion is not possible. More... | |
int | GetAsInteger (string key) |
Converts map element into an integer or returns 0 if conversion is not possible. More... | |
int | GetAsIntegerWithDefault (string key, int defaultValue) |
Converts map element into an integer or returns default value if conversion is not possible. More... | |
long | GetAsNullableLong (string key) |
Converts map element into a long or returns null if conversion is not possible. More... | |
long | GetAsLong (string key) |
Converts map element into a long or returns 0 if conversion is not possible. More... | |
long | GetAsLongWithDefault (string key, long defaultValue) |
Converts map element into a long or returns default value if conversion is not possible. More... | |
float | GetAsNullableFloat (string key) |
Converts map element into a float or returns null if conversion is not possible. More... | |
float | GetAsFloat (string key) |
Converts map element into a float or returns 0 if conversion is not possible. More... | |
float | GetAsFloatWithDefault (string key, float defaultValue) |
Converts map element into a float or returns default value if conversion is not possible. More... | |
double | GetAsNullableDouble (string key) |
Converts map element into a double or returns null if conversion is not possible. More... | |
double | GetAsDouble (string key) |
Converts map element into a double or returns 0 if conversion is not possible. More... | |
double | GetAsDoubleWithDefault (string key, double defaultValue) |
Converts map element into a double or returns default value if conversion is not possible. More... | |
DateTime | GetAsNullableDateTime (string key) |
Converts map element into a Date or returns null if conversion is not possible. More... | |
DateTime | GetAsDateTime (string key) |
Converts map element into a Date or returns current date if conversion is not possible. More... | |
DateTime | GetAsDateTimeWithDefault (string key, DateTime? defaultValue) |
Converts map element into a Date or returns default value if conversion is not possible. More... | |
TimeSpan | GetAsNullableTimeSpan (string key) |
TimeSpan | GetAsTimeSpan (string key) |
TimeSpan | GetAsTimeSpanWithDefault (string key, TimeSpan? defaultValue) |
T | GetAsNullableEnum< T > (string key) |
T | GetAsEnum< T > (string key) |
T | GetAsEnumWithDefault< T > (string key, T defaultValue) |
T | GetAsNullableType< T > (string key) |
Converts map element into a value defined by specied typecode. If conversion is not possible it returns null. More... | |
T | GetAsType< T > (string key) |
Converts map element into a value defined by specied typecode. If conversion is not possible it returns default value for the specied typecode. More... | |
T | GetAsTypeWithDefault< T > (string key, T defaultValue) |
Converts map element into a value defined by specied typecode. If conversion is not possible it returns default value. More... | |
AnyValue | GetAsValue (string key) |
Converts map element into an AnyValue or returns an empty AnyValue if conversion is not possible. More... | |
AnyValueArray | GetAsNullableArray (string key) |
Converts map element into an AnyValueArray or returns null if conversion is not possible. More... | |
AnyValueArray | GetAsArray (string key) |
Converts map element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible. More... | |
AnyValueArray | GetAsArrayWithDefault (string key, AnyValueArray defaultValue) |
Converts map element into an AnyValueArray or returns default value if conversion is not possible. More... | |
AnyValueMap | GetAsNullableMap (string key) |
Converts map element into an AnyValueMap or returns null if conversion is not possible. More... | |
AnyValueMap | GetAsMap (string key) |
Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible. More... | |
AnyValueMap | GetAsMapWithDefault (string key, AnyValueMap defaultValue) |
Converts map element into an AnyValueMap or returns default value if conversion is not possible. More... | |
override string | ToString () |
Gets a string representation of the object. The result is a semicolon-separated list of key-value pairs as "key1=value1;key2=value2;key=value3" More... | |
object | Clone () |
Creates a binary clone of this object. More... | |
Static Public Member Functions | |
static StringValueMap | FromValue (object value) |
Converts specified value into StringValueMap. More... | |
static StringValueMap | FromTuples (params object[] tuples) |
Creates a new StringValueMap from a list of key-value pairs called tuples. More... | |
static StringValueMap | FromString (string line) |
arses semicolon-separated key-value pairs and returns them as a StringValueMap. More... | |
static StringValueMap | FromMaps (params IDictionary< string, string >[] maps) |
Creates a new StringValueMap by merging two or more maps. Maps defined later in the list override values from previously defined maps. More... | |
Properties | |
new string | this[string key] [get, set] |
Cross-language implementation of a map (dictionary) where all keys and values are strings. The stored values can be converted to different types using variety of accessor methods.
The string map is highly versatile.It can be converted into many formats, stored and sent over the wire.
This class is widely used in Pip.Services as a basis for variety of classes, such as ConfigParams, ConnectionParams, CredentialParams and others.
See StringConverter, BooleanConverter, IntegerConverter, LongConverter, DoubleConverter, FloatConverter, DateTimeConverter, ICloneable
PipServices3.Commons.Data.StringValueMap.StringValueMap | ( | ) |
Creates a new instance of the map and assigns its value.
PipServices3.Commons.Data.StringValueMap.StringValueMap | ( | IDictionary< string, string > | map | ) |
Creates a new instance of the map and assigns its value.
map | (optional) values to initialize this map. |
PipServices3.Commons.Data.StringValueMap.StringValueMap | ( | object | value | ) |
Creates a new instance of the map and assigns its value.
value | (optional) values to initialize this map. |
void PipServices3.Commons.Data.StringValueMap.Append | ( | IDictionary< string, object > | map | ) |
Appends new elements to this map.
map | a map with elements to be added. |
void PipServices3.Commons.Data.StringValueMap.Append | ( | IDictionary< string, string > | map | ) |
Appends new elements to this map.
map | a map with elements to be added. |
object PipServices3.Commons.Data.StringValueMap.Clone | ( | ) |
Creates a binary clone of this object.
|
static |
Creates a new StringValueMap by merging two or more maps. Maps defined later in the list override values from previously defined maps.
maps | an array of maps to be merged |
|
static |
arses semicolon-separated key-value pairs and returns them as a StringValueMap.
line | semicolon-separated key-value list to initialize StringValueMap. |
|
static |
Creates a new StringValueMap from a list of key-value pairs called tuples.
tuples | a list of values where odd elements are keys and the following even elements are values |
|
static |
Converts specified value into StringValueMap.
value | value to be converted |
|
virtual |
Gets a map element specified by its key.
key | a key of the element to get. |
AnyValueArray PipServices3.Commons.Data.StringValueMap.GetAsArray | ( | string | key | ) |
Converts map element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.
key | a key of element to get. |
AnyValueArray PipServices3.Commons.Data.StringValueMap.GetAsArrayWithDefault | ( | string | key, |
AnyValueArray | defaultValue | ||
) |
Converts map element into an AnyValueArray or returns default value if conversion is not possible.
key | a key of element to get. |
defaultValue | the default value |
bool PipServices3.Commons.Data.StringValueMap.GetAsBoolean | ( | string | key | ) |
Converts map element into a boolean or returns false if conversion is not possible.
key | a key of element to get. |
bool PipServices3.Commons.Data.StringValueMap.GetAsBooleanWithDefault | ( | string | key, |
bool | defaultValue | ||
) |
Converts map element into a boolean or returns default value if conversion is not possible.
key | a key of element to get. |
defaultValue | the default value |
See BooleanConverter.ToBooleanWithDefault(object, bool)
DateTime PipServices3.Commons.Data.StringValueMap.GetAsDateTime | ( | string | key | ) |
Converts map element into a Date or returns current date if conversion is not possible.
key | a key of element to get. |
DateTime PipServices3.Commons.Data.StringValueMap.GetAsDateTimeWithDefault | ( | string | key, |
DateTime? | defaultValue | ||
) |
Converts map element into a Date or returns default value if conversion is not possible.
key | a key of element to get. |
defaultValue | the default value |
See DateTimeConverter.ToDateTimeWithDefault(object, DateTime?)
double PipServices3.Commons.Data.StringValueMap.GetAsDouble | ( | string | key | ) |
Converts map element into a double or returns 0 if conversion is not possible.
key | a key of element to get. |
double PipServices3.Commons.Data.StringValueMap.GetAsDoubleWithDefault | ( | string | key, |
double | defaultValue | ||
) |
Converts map element into a double or returns default value if conversion is not possible.
key | a key of element to get. |
defaultValue | the default value |
See DoubleConverter.ToDoubleWithDefault(object, double)
float PipServices3.Commons.Data.StringValueMap.GetAsFloat | ( | string | key | ) |
Converts map element into a float or returns 0 if conversion is not possible.
key | a key of element to get. |
float PipServices3.Commons.Data.StringValueMap.GetAsFloatWithDefault | ( | string | key, |
float | defaultValue | ||
) |
Converts map element into a float or returns default value if conversion is not possible.
key | a key of element to get. |
defaultValue | the default value |
See FloatConverter.ToFloatWithDefault(object, float)
int PipServices3.Commons.Data.StringValueMap.GetAsInteger | ( | string | key | ) |
Converts map element into an integer or returns 0 if conversion is not possible.
key | a key of element to get. |
int PipServices3.Commons.Data.StringValueMap.GetAsIntegerWithDefault | ( | string | key, |
int | defaultValue | ||
) |
Converts map element into an integer or returns default value if conversion is not possible.
key | a key of element to get. |
defaultValue | the default value |
See IntegerConverter.ToIntegerWithDefault(object, int)
long PipServices3.Commons.Data.StringValueMap.GetAsLong | ( | string | key | ) |
Converts map element into a long or returns 0 if conversion is not possible.
key | a key of element to get. |
long PipServices3.Commons.Data.StringValueMap.GetAsLongWithDefault | ( | string | key, |
long | defaultValue | ||
) |
Converts map element into a long or returns default value if conversion is not possible.
key | a key of element to get. |
defaultValue | the default value |
See LongConverter.ToLongWithDefault(object, long)
AnyValueMap PipServices3.Commons.Data.StringValueMap.GetAsMap | ( | string | key | ) |
Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.
key | a key of element to get. |
AnyValueMap PipServices3.Commons.Data.StringValueMap.GetAsMapWithDefault | ( | string | key, |
AnyValueMap | defaultValue | ||
) |
Converts map element into an AnyValueMap or returns default value if conversion is not possible.
key | a key of element to get. |
defaultValue | the default value |
AnyValueArray PipServices3.Commons.Data.StringValueMap.GetAsNullableArray | ( | string | key | ) |
Converts map element into an AnyValueArray or returns null if conversion is not possible.
key | a key of element to get. |
See AnyValueArray
bool PipServices3.Commons.Data.StringValueMap.GetAsNullableBoolean | ( | string | key | ) |
Converts map element into a boolean or returns null if conversion is not possible.
key | a key of element to get. |
See BooleanConverter.ToNullableBoolean(object)
DateTime PipServices3.Commons.Data.StringValueMap.GetAsNullableDateTime | ( | string | key | ) |
Converts map element into a Date or returns null if conversion is not possible.
key | a key of element to get. |
See DateTimeConverter.ToNullableDateTime(object)
double PipServices3.Commons.Data.StringValueMap.GetAsNullableDouble | ( | string | key | ) |
Converts map element into a double or returns null if conversion is not possible.
key | a key of element to get. |
See DoubleConverter.ToNullableDouble(object)
float PipServices3.Commons.Data.StringValueMap.GetAsNullableFloat | ( | string | key | ) |
Converts map element into a float or returns null if conversion is not possible.
key | a key of element to get. |
See FloatConverter.ToNullableFloat(object)
int PipServices3.Commons.Data.StringValueMap.GetAsNullableInteger | ( | string | key | ) |
Converts map element into an integer or returns null if conversion is not possible.
key | a key of element to get. |
See IntegerConverter.ToNullableInteger(object)
long PipServices3.Commons.Data.StringValueMap.GetAsNullableLong | ( | string | key | ) |
Converts map element into a long or returns null if conversion is not possible.
key | a key of element to get. |
See LongConverter.ToNullableLong(object)
AnyValueMap PipServices3.Commons.Data.StringValueMap.GetAsNullableMap | ( | string | key | ) |
Converts map element into an AnyValueMap or returns null if conversion is not possible.
key | a key of element to get. |
string PipServices3.Commons.Data.StringValueMap.GetAsNullableString | ( | string | key | ) |
Converts map element into a string or returns null if conversion is not possible.
key | a key of element to get. |
See StringConverter.ToNullableString(object)
T PipServices3.Commons.Data.StringValueMap.GetAsNullableType< T > | ( | string | key | ) |
Converts map element into a value defined by specied typecode. If conversion is not possible it returns null.
T | the class type |
key | a key of element to get. |
See TypeConverter.ToNullableType<T>(object)
T | : | struct |
object PipServices3.Commons.Data.StringValueMap.GetAsObject | ( | ) |
Gets the value stored in this map element without any conversions
object PipServices3.Commons.Data.StringValueMap.GetAsObject | ( | string | key | ) |
Gets the value stored in map element without any conversions. When element key is not defined it returns the entire map value.
key | (optional) a key of the element to get |
string PipServices3.Commons.Data.StringValueMap.GetAsString | ( | string | key | ) |
Converts map element into a string or returns "" if conversion is not possible.
key | a key of element to get. |
string PipServices3.Commons.Data.StringValueMap.GetAsStringWithDefault | ( | string | key, |
string | defaultValue | ||
) |
Converts map element into a string or returns default value if conversion is not possible.
key | a key of element to get. |
defaultValue | the default value |
See StringConverter.ToStringWithDefault(object, string)
T PipServices3.Commons.Data.StringValueMap.GetAsType< T > | ( | string | key | ) |
Converts map element into a value defined by specied typecode. If conversion is not possible it returns default value for the specied typecode.
T | the class type |
key | a key of element to get. |
See TypeConverter.ToType<T>(object)
T | : | struct |
T PipServices3.Commons.Data.StringValueMap.GetAsTypeWithDefault< T > | ( | string | key, |
T | defaultValue | ||
) |
Converts map element into a value defined by specied typecode. If conversion is not possible it returns default value.
T | the class type |
key | a key of element to get. |
defaultValue | the default value |
See TypeConverter.ToTypeWithDefault<T>(object, T)
T | : | struct |
AnyValue PipServices3.Commons.Data.StringValueMap.GetAsValue | ( | string | key | ) |
|
virtual |
Sets a new value for this array element by its key
key | a key of the element to set. |
value | the new object value. |
void PipServices3.Commons.Data.StringValueMap.SetAsObject | ( | object | value | ) |
Sets a new value for this array element
value | the new object value. |
void PipServices3.Commons.Data.StringValueMap.SetAsObject | ( | string | key, |
object | value | ||
) |
Sets a new value to map element specified by its index. When the index is not defined, it resets the entire map value.This method has double purpose because method overrides are not supported in JavaScript.
key | (optional) a key of the element to set |
value | a new element or map value. |
override string PipServices3.Commons.Data.StringValueMap.ToString | ( | ) |
Gets a string representation of the object. The result is a semicolon-separated list of key-value pairs as "key1=value1;key2=value2;key=value3"