Class ResourceQuery
Definition
- Namespace:
- Tizen.Network.IoTConnectivity
- Assembly:
- Tizen.Network.IoTConnectivity.dll
- API Level:
- 3
This class provides APIs to manage the query of request.
C#Copypublic class ResourceQuery : IDictionary<string, string>, ICollection<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, string>>, IEnumerable, IDisposable
- Inheritance
-
System.ObjectResourceQuery
- Implements
-
System.Collections.Generic.IDictionary<System.String, System.String>System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String, System.String>>System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.String>>System.Collections.IEnumerableSystem.IDisposable
Constructors
Declaration
C#Copypublic ResourceQuery()
Examples
CopyResourceQuery query = new ResourceQuery();
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 query elements. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add("key", "value"); query.Add("newKey", "sample value"); var count = query.Count; Console.WriteLine("There are {0} keys in the query object", count);
API Level: 3
Declaration
C#Copypublic string Interface { get; set; }
Property Value
Type | Description |
---|---|
System.String | The resource interface of the query. Setter value could be a value, such as DefaultInterface. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Interface = ResourceInterfaces.LinkInterface;
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
Declaration
C#Copypublic bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Whether the collection is readonly. |
Examples
CopyResourceQuery query = new ResourceQuery(); if (query.IsReadOnly) Console.WriteLine("Read only query");
API Level: 3
Declaration
C#Copypublic string this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The query key to get or set. |
Property Value
Type | Description |
---|---|
System.String | The query data. |
Examples
CopyResourceQuery query = new ResourceQuery(); query["key1"] = "sample-data"; Console.WriteLine("query has : {0}", query["key1"]);
API Level: 3
Declaration
C#Copypublic ICollection<string> Keys { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> | All the query keys. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add("key", "value"); query.Add("newKey", "sample value"); var keys = query.Keys; Console.WriteLine("Resource query contains keys {0} and {1}", keys.ElementAt(0), keys.ElementAt(1));
API Level: 3
Declaration
C#Copypublic string Type { get; set; }
Property Value
Type | Description |
---|---|
System.String | The resource type of the query. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Type = "org.tizen.light"; Console.WriteLine("Type of query : {0}", query.Type);
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
Declaration
C#Copypublic ICollection<string> Values { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> | All the query values. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add("key", "value"); query.Add("newKey", "sample value"); var values = query.Values; Console.WriteLine("Resource query contains values {0} and {1}", values.ElementAt(0), values.ElementAt(1));
API Level: 3
Methods
Declaration
C#Copypublic void Add(KeyValuePair<string, string> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.String> | item | The key value pair. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add(new KeyValuePair<string, string>("key1", "value1"));
See Also
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Declaration
C#Copypublic void Add(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key of the query to insert. |
System.String | value | The string data to insert into the query. |
Remarks
The full length of query should be less than or equal to 64.
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add("key1", "value1");
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. |
See Also
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Declaration
C#Copypublic void Clear()
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add("key1", "value1"); query.Add("key2", "value2"); query.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
Declaration
C#Copypublic bool Contains(KeyValuePair<string, string> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.String> | item | The key value pair. |
Returns
Type | Description |
---|---|
System.Boolean | True if exists. Otherwise, false. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add(new KeyValuePair<string, string>("key1", "value1")); var isPresent = query.Contains(new KeyValuePair<string, string>("key1", "value1")); if (isPresent) Console.WriteLine("Key value pair is present");
API Level: 3
Declaration
C#Copypublic bool ContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to look for. |
Returns
Type | Description |
---|---|
System.Boolean | true if exists. Otherwise, false. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add("key1", "value1"); if (query.ContainsKey("key1")) Console.WriteLine("query conatins key : key1");
API Level: 3
CopyTo(KeyValuePair<String, String>[], Int32)
Copies the elements of the query collection to an array, starting at a particular index.
Declaration
C#Copypublic void CopyTo(KeyValuePair<string, string>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.String>[] | array | The destination array. |
System.Int32 | arrayIndex | Index parameter. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add(new KeyValuePair<string, string>("key1", "value1")); KeyValuePair<string, string>[] dest = new KeyValuePair<string, string>[query.Count]; query.CopyTo(dest, 0); 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, string>> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String, System.String>> | Enumerator to query pairs. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add(new KeyValuePair<string, string>("key1", "value1")); query.Add(new KeyValuePair<string, string>("key2", "value2")); foreach (KeyValuePair<string, string> pair in query) { Console.WriteLine("key : {0}, value : {1}", pair.Key, pair.Value); }
API Level: 3
Declaration
C#Copypublic bool Remove(KeyValuePair<string, string> item)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<System.String, System.String> | item | The key value pair to remove. |
Returns
Type | Description |
---|---|
System.Boolean | True if operation is successful. Otherwise, false. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add(new KeyValuePair<string, string>("key1", "value1")); var result = query.Remove(new KeyValuePair<string, string>("key1", "value1"));
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when there is an invalid parameter. |
See Also
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 ID of the query to delete. |
Returns
Type | Description |
---|---|
System.Boolean | True if operation is successful. Otherwise, false. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add("key1", "value1"); var result = query.Remove("key1");
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. |
See Also
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Declaration
C#Copypublic bool TryGetValue(string key, out string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The query key. |
System.String | value | Value corresponding to query key. |
Returns
Type | Description |
---|---|
System.Boolean | True if the key exists, false otherwise. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add("key1", "value1"); string value; var isPresent = query.TryGetValue("key1", 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 | The enumerator to the query pairs. |
Examples
CopyResourceQuery query = new ResourceQuery(); query.Add(new KeyValuePair<string, string>("key1", "value1")); query.Add(new KeyValuePair<string, string>("key2", "value2")); foreach (KeyValuePair<string, string> pair in query) { Console.WriteLine("key : {0}, value : {1}", pair.Key, pair.Value); }