Class Attributes
Definition
- Namespace:
- Tizen.Network.IoTConnectivity
- Assembly:
- Tizen.Network.IoTConnectivity.dll
- API Level:
- 3
This class represents current attributes of a resource. It provides API to manage attributes. This class is accessed by using a constructor to create a new instance of this object.
C#Copypublic class Attributes : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable, IDisposable
- Inheritance
-
System.ObjectAttributes
- Implements
-
System.Collections.Generic.IDictionary<System.String, System.Object>System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String, System.Object>>System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.Object>>System.Collections.IEnumerableSystem.IDisposable
Constructors
Declaration
C#Copypublic Attributes()
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
OutOfMemoryException | Thrown when there is not enough memory. |
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Properties
Declaration
C#Copypublic int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The number of keys. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { attributes.Add("brightness", 50); var count = attributes.Count; Console.WriteLine("There are {0} keys in the attribute object", count);
API Level: 3
Declaration
C#Copypublic bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Whether an attribute is readonly. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" }, { "dim", 10 } }; if (attributes.IsReadOnly) Console.WriteLine("Read only attribute");
API Level: 3
Declaration
C#Copypublic object this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key of the attribute to get or set. |
Property Value
Type | Description |
---|---|
System.Object | The attribute with the specified key. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes(); attributes["state"] = "ON"; Console.WriteLine("Attribute value for key 'state' : {0}", attributes["state"]);
API Level: 3
Declaration
C#Copypublic ICollection<string> Keys { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> | All the attribute keys. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" }, { "dim", 10 } }; var keys = attributes.Keys; Console.WriteLine("Attribute contains keys {0} and {1}", keys.ElementAt(0), keys.ElementAt(1));
API Level: 3
Declaration
C#Copypublic ICollection<object> Values { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.Object> | All the attribute values. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" }, { "dim", 10 } }; var values = attributes.Values; Console.WriteLine("Attribute contains values {0} and {1}", values.ElementAt(0), values.ElementAt(1));
API Level: 3
Methods
Add(KeyValuePair<String, Object>)
Adds the attribute key and a value as a key value pair.
Declaration
C#Copypublic void Add(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.Object> | item | The key value pair to add. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes(); attributes.Add(new KeyValuePair<string, object> ("state", "ON"));
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Declaration
C#Copypublic void Add(string key, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key representing the attribute. |
System.Object | value | The value representing the attribute. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes(); attributes.Add("brightness", 50);
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Declaration
C#Copypublic void Clear()
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes(); attributes.Add("brightness", 50); attributes.Clear();
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported |
System.InvalidOperationException | Thrown when the operation is invalid |
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Contains(KeyValuePair<String, Object>)
Checks whether the given key value pair exists in attributes collection.
Declaration
C#Copypublic bool Contains(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.Object> | item | The status key value pair. |
Returns
Type | Description |
---|---|
System.Boolean | true if exists. Otherwise, false. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" }, { "dim", 10 } }; if (attributes.Contains(new KeyValuePair<string, object> ("dim", 10)) Console.WriteLine("Attribute conatins pair ('dim', 10)");
API Level: 3
Declaration
C#Copypublic bool ContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The status key to look for. |
Returns
Type | Description |
---|---|
System.Boolean | true if exists. Otherwise, false. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" }, { "dim", 10 } }; if (attributes.ContainsKey("dim")) Console.WriteLine("Attribute conatins key : dim");
API Level: 3
CopyTo(KeyValuePair<String, Object>[], Int32)
Copies the elements of the attributes to an array, starting at a particular index.
Declaration
C#Copypublic void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.Object>[] | array | The destination array. |
System.Int32 | arrayIndex | The zero-based index in an array at which copying begins. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" }, { "dim", 10 } }; KeyValuePair<string, object>[] dest = new KeyValuePair<string, object>[attributes.Count]; int index = 0; attributes.CopyTo(dest, index); Console.WriteLine("Dest conatins ({0}, {1})", dest[0].Key, dest[0].Value);
API Level: 3
Declaration
C#Copypublic void Dispose()
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Dispose(Boolean)
Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
Declaration
C#Copyprotected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | If true, disposes any disposable objects. If false, does not dispose disposable objects. |
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Declaration
C#Copyprotected void Finalize()
Declaration
C#Copypublic IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String, System.Object>> | An enumerator that can be used to iterate through the collection. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" }, { "dim", 10 } }; foreach (KeyValuePair<string, object> pair in attributes) { Console.WriteLine("key : {0}, value : {1}", pair.Key, pair.Value); }
API Level: 3
Declaration
C#Copypublic bool Remove(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.Object> | item | The attributes element to remove. |
Returns
Type | Description |
---|---|
System.Boolean | true if operation is successful, otherwise, false. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" }, { "dim", 10 } }; if (attributes.Remove(new KeyValuePair<string, object>("dim", 10))) Console.WriteLine("Remove was successful");
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported |
System.ArgumentException | Thrown when there is an invalid parameter |
System.InvalidOperationException | Thrown when the operation is invalid |
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Declaration
C#Copypublic bool Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The attributes element to remove. |
Returns
Type | Description |
---|---|
System.Boolean | true if operation is successful, otherwise, false. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" }, { "dim", 10 } }; if (attributes.Remove("state")) Console.WriteLine("Remove was successful");
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported |
System.ArgumentException | Thrown when there is an invalid parameter |
System.InvalidOperationException | Thrown when the operation is invalid |
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Declaration
C#Copypublic bool TryGetValue(string key, out object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key whose value to get. |
System.Object | value | The value associated with the specified key. |
Returns
Type | Description |
---|---|
System.Boolean | true if the attributes collection contains an element with the specified key, otherwise, false. |
Examples
CopyTizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() { { "state", "ON" } }; object value; var isPresent = attributes.TryGetValue("state", out value); if (isPresent) Console.WriteLine("value : {0}", value);
API Level: 3
Explicit Interface Implementations
Declaration
C#CopyIEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |