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#
Copy
public class ResourceQuery : IDictionary<string, string>, ICollection<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, string>>, IEnumerable, IDisposable
Inheritance
System.Object
ResourceQuery
Implements
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.IDisposable

Constructors

View Source

ResourceQuery()

The resource query constructor.

Declaration
C#
Copy
public ResourceQuery()
Examples
Copy
ResourceQuery 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

View Source

Count

Gets the number of query elements.

Declaration
C#
Copy
public int Count { get; }
Property Value
Type Description
Int32

The number of query elements.

Examples
Copy
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 Source

Interface

Gets and sets the resource interface of the query.

Declaration
C#
Copy
public 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
Copy
ResourceQuery 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
View Source

IsReadOnly

Represents whether the collection is readonly.

Declaration
C#
Copy
public bool IsReadOnly { get; }
Property Value
Type Description
Boolean

Whether the collection is readonly.

Examples
Copy
ResourceQuery query = new ResourceQuery(); if (query.IsReadOnly) Console.WriteLine("Read only query");
API Level: 3
View Source

Item[String]

Gets or sets the query data.

Declaration
C#
Copy
public 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
Copy
ResourceQuery query = new ResourceQuery(); query["key1"] = "sample-data"; Console.WriteLine("query has : {0}", query["key1"]);
API Level: 3
View Source

Keys

Contains all the query keys.

Declaration
C#
Copy
public ICollection<string> Keys { get; }
Property Value
Type Description
System.Collections.Generic.ICollection<System.String>

All the query keys.

Examples
Copy
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 Source

Type

Gets and sets the resource type of the query.

Declaration
C#
Copy
public string Type { get; set; }
Property Value
Type Description
System.String

The resource type of the query.

Examples
Copy
ResourceQuery 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
View Source

Values

Contains all the query values.

Declaration
C#
Copy
public ICollection<string> Values { get; }
Property Value
Type Description
System.Collections.Generic.ICollection<System.String>

All the query values.

Examples
Copy
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 Source

Add(KeyValuePair<String, String>)

Adds a query key and a value as a key value pair.

Declaration
C#
Copy
public void Add(KeyValuePair<string, string> item)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<System.String, System.String> item

The key value pair.

Examples
Copy
ResourceQuery query = new ResourceQuery(); query.Add(new KeyValuePair<string, string>("key1", "value1"));
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View Source

Add(String, String)

Adds a new key and correspoding value into the query.

Declaration
C#
Copy
public 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
Copy
ResourceQuery 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
View Source

Clear()

Clears the query collection.

Declaration
C#
Copy
public void Clear()
Examples
Copy
ResourceQuery 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
View Source

Contains(KeyValuePair<String, String>)

Checks if the given query pair exists.

Declaration
C#
Copy
public 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
Boolean

True if exists. Otherwise, false.

Examples
Copy
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 Source

ContainsKey(String)

Checks whether the given key exists in the query collection.

Declaration
C#
Copy
public bool ContainsKey(string key)
Parameters
Type Name Description
System.String key

The key to look for.

Returns
Type Description
Boolean

true if exists. Otherwise, false.

Examples
Copy
ResourceQuery query = new ResourceQuery(); query.Add("key1", "value1"); if (query.ContainsKey("key1")) Console.WriteLine("query conatins key : key1");
API Level: 3
View Source

CopyTo(KeyValuePair<String, String>[], Int32)

Copies the elements of the query collection to an array, starting at a particular index.

Declaration
C#
Copy
public void CopyTo(KeyValuePair<string, string>[] array, int arrayIndex)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<System.String, System.String>[] array

The destination array.

Int32 arrayIndex

Index parameter.

Examples
Copy
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 Source

Dispose()

Releases any unmanaged resources used by this object.

Declaration
C#
Copy
public void Dispose()
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View Source

Dispose(Boolean)

Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.

Declaration
C#
Copy
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 Source

Finalize()

Destructor of the ResourceQuery class.

Declaration
C#
Copy
protected void Finalize()
View Source

GetEnumerator()

Gets the enumerator to the query collection.

Declaration
C#
Copy
public 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
Copy
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 Source

Remove(KeyValuePair<String, String>)

Removes the given key value pair from the query.

Declaration
C#
Copy
public 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
Boolean

True if operation is successful. Otherwise, false.

Examples
Copy
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
System.ArgumentException

Thrown when there is an invalid parameter.

API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View Source

Remove(String)

Removes the key and its associated value from the query.

Declaration
C#
Copy
public bool Remove(string key)
Parameters
Type Name Description
System.String key

The ID of the query to delete.

Returns
Type Description
Boolean

True if operation is successful. Otherwise, false.

Examples
Copy
ResourceQuery 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.

API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View Source

TryGetValue(String, out String)

Gets the value associated with the specified key.

Declaration
C#
Copy
public 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
Boolean

True if the key exists, false otherwise.

Examples
Copy
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 Source

IEnumerable.GetEnumerator()

Gets the enumerator to the query collection.

Declaration
C#
Copy
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

The enumerator to the query pairs.

Examples
Copy
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

Implements

System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.IDisposable