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.
public class Attributes : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable, IDisposable
- Inheritance
-
Attributes
- Implements
Constructors
View SourceAttributes()
The Attributes constructor.
Declaration
public Attributes()
Examples
Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
Exceptions
Type | Condition |
---|---|
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
View SourceCount
Gets the number of keys.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 | The number of keys. |
Examples
Tizen.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
View SourceIsReadOnly
Represents whether an attribute is readonly.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
Boolean | Whether an attribute is readonly. |
Examples
Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes() {
{ "state", "ON" },
{ "dim", 10 }
};
if (attributes.IsReadOnly)
Console.WriteLine("Read only attribute");
API Level: 3
View SourceItem[String]
Gets or sets the attribute with the specified key.
Declaration
public object this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
String | key | The key of the attribute to get or set. |
Property Value
Type | Description |
---|---|
Object | The attribute with the specified key. |
Examples
Tizen.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
View SourceKeys
Contains all the attribute keys.
Declaration
public ICollection<string> Keys { get; }
Property Value
Type | Description |
---|---|
ICollection<String> | All the attribute keys. |
Examples
Tizen.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
View SourceValues
Contains all the attribute values.
Declaration
public ICollection<object> Values { get; }
Property Value
Type | Description |
---|---|
ICollection<Object> | All the attribute values. |
Examples
Tizen.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
View SourceAdd(KeyValuePair<String, Object>)
Adds the attribute key and a value as a key value pair.
Declaration
public void Add(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<String, Object> | item | The key value pair to add. |
Examples
Tizen.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
View SourceAdd(String, Object)
Adds an attribute.
Declaration
public void Add(string key, object value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key representing the attribute. |
Object | value | The value representing the attribute. |
Examples
Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
attributes.Add("brightness", 50);
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View SourceClear()
Clears attributes collection.
Declaration
public void Clear()
Examples
Tizen.Network.IoTConnectivity.Attributes attributes = new Tizen.Network.IoTConnectivity.Attributes();
attributes.Add("brightness", 50);
attributes.Clear();
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown when the iotcon is not supported |
InvalidOperationException | Thrown when the operation is invalid |
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View SourceContains(KeyValuePair<String, Object>)
Checks whether the given key value pair exists in attributes collection.
Declaration
public bool Contains(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<String, Object> | item | The status key value pair. |
Returns
Type | Description |
---|---|
Boolean | true if exists. Otherwise, false. |
Examples
Tizen.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
View SourceContainsKey(String)
Checks whether the given key exists in attributes collection.
Declaration
public bool ContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The status key to look for. |
Returns
Type | Description |
---|---|
Boolean | true if exists. Otherwise, false. |
Examples
Tizen.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
View SourceCopyTo(KeyValuePair<String, Object>[], Int32)
Copies the elements of the attributes to an array, starting at a particular index.
Declaration
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<String, Object>[] | array | The destination array. |
Int32 | arrayIndex | The zero-based index in an array at which copying begins. |
Examples
Tizen.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
View SourceDispose()
Releases any unmanaged resources used by this object.
Declaration
public void Dispose()
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View SourceDispose(Boolean)
Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
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
View SourceFinalize()
Destructor of the Attributes class.
Declaration
protected void Finalize()
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<String, Object>> | An enumerator that can be used to iterate through the collection. |
Examples
Tizen.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
View SourceRemove(KeyValuePair<String, Object>)
Removes an attribute from collection.
Declaration
public bool Remove(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<String, Object> | item | The attributes element to remove. |
Returns
Type | Description |
---|---|
Boolean | true if operation is successful, otherwise, false. |
Examples
Tizen.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 |
---|---|
NotSupportedException | Thrown when the iotcon is not supported |
ArgumentException | Thrown when there is an invalid parameter |
InvalidOperationException | Thrown when the operation is invalid |
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View SourceRemove(String)
Removes an attribute from collection using a key.
Declaration
public bool Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The attributes element to remove. |
Returns
Type | Description |
---|---|
Boolean | true if operation is successful, otherwise, false. |
Examples
Tizen.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 |
---|---|
NotSupportedException | Thrown when the iotcon is not supported |
ArgumentException | Thrown when there is an invalid parameter |
InvalidOperationException | Thrown when the operation is invalid |
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View SourceTryGetValue(String, out Object)
Gets the value associated with the specified key.
Declaration
public bool TryGetValue(string key, out object value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key whose value to get. |
Object | value | The value associated with the specified key. |
Returns
Type | Description |
---|---|
Boolean | true if the attributes collection contains an element with the specified key, otherwise, false. |
Examples
Tizen.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
View SourceIEnumerable.GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator |