Class DictionaryObject
A class representing a key-value collection that is read only
Implements
Namespace: Couchbase.Lite
Assembly: Couchbase.Lite.dll
Syntax
public class DictionaryObject : object, IDictionaryObject, IDictionaryFragment, IEnumerable<KeyValuePair<string, object>>, IJSON
Properties
| Improve this Doc View SourceCount
Gets the number of entries in this dictionary
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[String]
Gets the value of the given key, or lack thereof, wrapped inside of a IFragment
Declaration
public IFragment this[string key] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check |
Property Value
Type | Description |
---|---|
IFragment | The value of the given key, or lack thereof |
Keys
Gets all the keys held by this dictionary
Declaration
public ICollection<string> Keys { get; }
Property Value
Type | Description |
---|---|
ICollection<System.String> |
Methods
| Improve this Doc View SourceContains(String)
Checks if a given key is present in the dictionary
Declaration
public bool Contains(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check for |
Returns
Type | Description |
---|---|
System.Boolean |
|
GetArray(String)
Gets the value of a given key as an IArray
Declaration
public ArrayObject GetArray(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
ArrayObject | The contained value, or |
GetBlob(String)
Gets the value of a given key as a Blob
Declaration
public Blob GetBlob(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
Blob | The contained value, or |
GetBoolean(String)
Gets the value of a given key as a
Declaration
public bool GetBoolean(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
System.Boolean | The contained value, or its converted equivalent |
Remarks
Any non-zero object will be treated as true, so don't rely on any sort of parsing
GetDate(String)
Gets the value of a given key as a
Declaration
public DateTimeOffset GetDate(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
DateTimeOffset | The contained value, or a default value |
GetDictionary(String)
Gets the value of a given key as a readonly dictionary
Declaration
public DictionaryObject GetDictionary(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
DictionaryObject | The contained value, or |
GetDouble(String)
Gets the value of a given key as a
Declaration
public double GetDouble(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
System.Double | The contained value, or its converted equivalent |
Remarks
true
will be converted to 1.0, and everything else that
is non-numeric will be 0.0
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public virtual IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<System.String, System.Object>> | An enumerator that can be used to iterate through the collection. |
GetFloat(String)
Gets the value of a given key as a
Declaration
public float GetFloat(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
System.Single | The contained value, or its converted equivalent |
Remarks
true
will be converted to 1.0f, and everything else that
is non-numeric will be 0.0f
GetInt(String)
Gets the value of a given key as an
Declaration
public int GetInt(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
System.Int32 | The contained value, or its converted equivalent |
Remarks
true
will be converted to 1, a
GetLong(String)
Gets the value of a given key as an
Declaration
public long GetLong(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
System.Int64 | The contained value, or its converted equivalent |
Remarks
true
will be converted to 1, a
GetString(String)
Gets the value of a given key as a
Declaration
public string GetString(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
System.String | The contained value, or |
GetValue(String)
Gets the value of a given key as an untyped object
Declaration
public object GetValue(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to check the value for |
Returns
Type | Description |
---|---|
System.Object | The contained value, or |
Remarks
This method should be avoided for numeric types, whose
underlying representation is subject to change and thus
KeysChanged()
Signal that the keys of this object have changed (not possible for this class, but a subclass might)
Declaration
protected void KeysChanged()
ToDictionary()
Converts this object to a standard .NET string to object
Declaration
public Dictionary<string, object> ToDictionary()
Returns
Type | Description |
---|---|
Dictionary<System.String, System.Object> | The contents of this object as a .NET dictionary |
ToJSON()
Converts this object to JSON format string.
Declaration
public string ToJSON()
Returns
Type | Description |
---|---|
System.String | The contents of this object in JSON format string |
ToMutable()
Creates a copy of this object that can be mutated
Declaration
public MutableDictionaryObject ToMutable()
Returns
Type | Description |
---|---|
MutableDictionaryObject | A mutable copy of the dictionary |