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.
public class ResourceQuery : IDictionary<string, string>, ICollection<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, string>>, IEnumerable, IDisposable
- Inheritance
-
ResourceQuery
- Implements
Constructors
View SourceResourceQuery()
The resource query constructor.
Declaration
public ResourceQuery()
Examples
ResourceQuery query = new ResourceQuery();
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown when the iotcon is not supported. |
OutOfMemoryException | Thrown when there is not enough memory. |
See Also
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Properties
View SourceCount
Gets the number of query elements.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 | The number of query elements. |
Examples
ResourceQuery 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
View SourceInterface
Gets and sets the resource interface of the query.
Declaration
public string Interface { get; set; }
Property Value
Type | Description |
---|---|
String | The resource interface of the query. Setter value could be a value, such as DefaultInterface. |
Examples
ResourceQuery query = new ResourceQuery();
query.Interface = ResourceInterfaces.LinkInterface;
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
View SourceIsReadOnly
Represents whether the collection is readonly.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
Boolean | Whether the collection is readonly. |
Examples
ResourceQuery query = new ResourceQuery();
if (query.IsReadOnly)
Console.WriteLine("Read only query");
API Level: 3
View SourceItem[String]
Gets or sets the query data.
Declaration
public string this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
String | key | The query key to get or set. |
Property Value
Type | Description |
---|---|
String | The query data. |
Examples
ResourceQuery query = new ResourceQuery();
query["key1"] = "sample-data";
Console.WriteLine("query has : {0}", query["key1"]);
API Level: 3
View SourceKeys
Contains all the query keys.
Declaration
public ICollection<string> Keys { get; }
Property Value
Type | Description |
---|---|
ICollection<String> | All the query keys. |
Examples
ResourceQuery 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
View SourceType
Gets and sets the resource type of the query.
Declaration
public string Type { get; set; }
Property Value
Type | Description |
---|---|
String | The resource type of the query. |
Examples
ResourceQuery query = new ResourceQuery();
query.Type = "org.tizen.light";
Console.WriteLine("Type of query : {0}", query.Type);
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
View SourceValues
Contains all the query values.
Declaration
public ICollection<string> Values { get; }
Property Value
Type | Description |
---|---|
ICollection<String> | All the query values. |
Examples
ResourceQuery 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
View SourceAdd(KeyValuePair<String, String>)
Adds a query key and a value as a key value pair.
Declaration
public void Add(KeyValuePair<string, string> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<String, String> | item | The key value pair. |
Examples
ResourceQuery query = new ResourceQuery();
query.Add(new KeyValuePair<string, string>("key1", "value1"));
See Also
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View SourceAdd(String, String)
Adds a new key and correspoding value into the query.
Declaration
public void Add(string key, string value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key of the query to insert. |
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
ResourceQuery query = new ResourceQuery();
query.Add("key1", "value1");
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. |
See Also
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View SourceClear()
Clears the query collection.
Declaration
public void Clear()
Examples
ResourceQuery query = new ResourceQuery();
query.Add("key1", "value1");
query.Add("key2", "value2");
query.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, String>)
Checks if the given query pair exists.
Declaration
public bool Contains(KeyValuePair<string, string> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<String, String> | item | The key value pair. |
Returns
Type | Description |
---|---|
Boolean | True if exists. Otherwise, false. |
Examples
ResourceQuery 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
View SourceContainsKey(String)
Checks whether the given key exists in the query collection.
Declaration
public bool ContainsKey(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key to look for. |
Returns
Type | Description |
---|---|
Boolean | true if exists. Otherwise, false. |
Examples
ResourceQuery query = new ResourceQuery();
query.Add("key1", "value1");
if (query.ContainsKey("key1"))
Console.WriteLine("query conatins key : key1");
API Level: 3
View SourceCopyTo(KeyValuePair<String, String>[], Int32)
Copies the elements of the query collection to an array, starting at a particular index.
Declaration
public void CopyTo(KeyValuePair<string, string>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<String, String>[] | array | The destination array. |
Int32 | arrayIndex | Index parameter. |
Examples
ResourceQuery 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
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 ResourceQuery class.
Declaration
protected void Finalize()
GetEnumerator()
Gets the enumerator to the query collection.
Declaration
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<String, String>> | Enumerator to query pairs. |
Examples
ResourceQuery 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
View SourceRemove(KeyValuePair<String, String>)
Removes the given key value pair from the query.
Declaration
public bool Remove(KeyValuePair<string, string> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<String, String> | item | The key value pair to remove. |
Returns
Type | Description |
---|---|
Boolean | True if operation is successful. Otherwise, false. |
Examples
ResourceQuery query = new ResourceQuery();
query.Add(new KeyValuePair<string, string>("key1", "value1"));
var result = query.Remove(new KeyValuePair<string, string>("key1", "value1"));
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when there is an invalid parameter. |
See Also
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View SourceRemove(String)
Removes the key and its associated value from the query.
Declaration
public bool Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The ID of the query to delete. |
Returns
Type | Description |
---|---|
Boolean | True if operation is successful. Otherwise, false. |
Examples
ResourceQuery query = new ResourceQuery();
query.Add("key1", "value1");
var result = query.Remove("key1");
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. |
See Also
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View SourceTryGetValue(String, out String)
Gets the value associated with the specified key.
Declaration
public bool TryGetValue(string key, out string value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The query key. |
String | value | Value corresponding to query key. |
Returns
Type | Description |
---|---|
Boolean | True if the key exists, false otherwise. |
Examples
ResourceQuery 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
View SourceIEnumerable.GetEnumerator()
Gets the enumerator to the query collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | The enumerator to the query pairs. |
Examples
ResourceQuery 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);
}