/// <summary>
/// This class provides APIs to manage query of request.
/// </summary>
+ /// <since_tizen>3</since_tizen>
public class ResourceQuery : IDictionary<string, string>, IDisposable
{
internal const int QueryMaxLenth = 64;
/// <summary>
/// The resource query constructor
/// </summary>
+ /// <since_tizen>3</since_tizen>
+ /// <feature>http://tizen.org/feature/iot.ocf</feature>
/// <seealso cref="Add()"/>
/// <seealso cref="Remove()"/>
/// <exception cref="NotSupportedException">Thrown when the iotcon is not supported</exception>
/// <exception cref="OutOfMemoryException">Thrown when there is not enough memory</exception>
- /// <exception cref="ArgumentException">Thrown when there is an invalid parameter</exception>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// </code>
/// <summary>
/// Gets and sets the resource type of the query
/// </summary>
+ /// <since_tizen>3</since_tizen>
+ /// <value>The resource type of the query.</value>
/// <exception cref="NotSupportedException">Thrown when the iotcon is not supported</exception>
/// <exception cref="ArgumentException">Thrown when there is an invalid parameter</exception>
/// <exception cref="InvalidOperationException">Thrown when the operation is invalid</exception>
/// <summary>
/// Gets and sets the resource interface of the query
/// </summary>
- /// <remarks>
+ /// <since_tizen>3</since_tizen>
+ /// <value>
+ /// The resource interface of the query.
/// Setter value could be a value such as <see cref="ResourceInterfaces.DefaultInterface"/>
- /// </remarks>
+ /// </value>
/// <exception cref="NotSupportedException">Thrown when the iotcon is not supported</exception>
/// <exception cref="ArgumentException">Thrown when there is an invalid parameter</exception>
/// <exception cref="InvalidOperationException">Thrown when the operation is invalid</exception>
/// <summary>
/// Contains all the query keys
/// </summary>
+ /// <since_tizen>3</since_tizen>
+ /// <value>All the query keys.</value>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// query.Add("key", "value");
/// <summary>
/// Contains all the query values
/// </summary>
+ /// <since_tizen>3</since_tizen>
+ /// <value>All the query values.</value>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// query.Add("key", "value");
/// <summary>
/// Gets the number of query elements
/// </summary>
+ /// <since_tizen>3</since_tizen>
+ /// <value>The number of query elements.</value>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// query.Add("key", "value");
/// <summary>
/// Represents whether the collection is readonly
/// </summary>
+ /// <since_tizen>3</since_tizen>
+ /// <value>Whether the collection is readonly.</value>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// if (query.IsReadOnly)
/// <summary>
/// Gets or sets the query data
/// </summary>
+ /// <since_tizen>3</since_tizen>
+ /// <value>The query data.</value>
/// <param name="key">The query key to get or set.</param>
/// <returns>The query with the specified key.</returns>
/// <code>
/// <summary>
/// Checks whether the given key exists in Query collection
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <param name="key">The key to look for</param>
/// <returns>true if exists. Otherwise, false</returns>
/// <code>
/// <summary>
/// Adds a new key and correspoding value into the query.
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <remarks>
/// The full length of query should be less than or equal to 64.
/// </remarks>
/// <param name="key">The key of the query to insert</param>
/// <param name="value">The string data to insert into the query</param>
+ /// <feature>http://tizen.org/feature/iot.ocf</feature>
/// <seealso cref="Remove()"/>
/// <exception cref="NotSupportedException">Thrown when the iotcon is not supported</exception>
/// <exception cref="ArgumentException">Thrown when there is an invalid parameter</exception>
/// <summary>
/// Removes the key and its associated value from the query.
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <param name="key">The id of the query to delete</param>
/// <returns>True if operation is successful. Otherwise, false</returns>
+ /// <feature>http://tizen.org/feature/iot.ocf</feature>
/// <seealso cref="Add()"/>
/// <exception cref="NotSupportedException">Thrown when the iotcon is not supported</exception>
/// <exception cref="ArgumentException">Thrown when there is an invalid parameter</exception>
/// </code>
public bool Remove(string key)
{
- bool isRemoved = _query.Remove(key);
- if (isRemoved)
+ int ret = Interop.IoTConnectivity.Common.Query.Remove(_resourceQueryHandle, key);
+ if (ret != (int)IoTConnectivityError.None)
{
- int ret = Interop.IoTConnectivity.Common.Query.Remove(_resourceQueryHandle, key);
- if (ret != (int)IoTConnectivityError.None)
- {
- Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove query");
- throw IoTConnectivityErrorFactory.GetException(ret);
- }
+ Log.Error(IoTConnectivityErrorFactory.LogTag, "Failed to remove query");
+ throw IoTConnectivityErrorFactory.GetException(ret);
}
+
+ bool isRemoved = _query.Remove(key);
+
return isRemoved;
}
/// <summary>
/// Gets the value associated with the specified key.
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <param name="key">The query key</param>
/// <param name="value">Value corresponding to query key</param>
/// <returns>True if the key exists, false otherwise</returns>
}
/// <summary>
- /// Adds query key and value as a key value pair
+ /// Adds query key and value as a key value pair
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <param name="item">The key value pair</param>
+ /// <feature>http://tizen.org/feature/iot.ocf</feature>
/// <seealso cref="Remove()"/>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// <summary>
/// Clears the Query collection
/// </summary>
+ /// <since_tizen>3</since_tizen>
+ /// <feature>http://tizen.org/feature/iot.ocf</feature>
/// <exception cref="NotSupportedException">Thrown when the iotcon is not supported</exception>
- /// <exception cref="ArgumentException">Thrown when there is an invalid parameter</exception>
/// <exception cref="InvalidOperationException">Thrown when the operation is invalid</exception>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// <summary>
/// Checks if the given query pair exists
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <param name="item">The key value pair</param>
/// <returns>True if exists. Otherwise, false</returns>
/// <code>
/// <summary>
/// Copies the elements of the query collection to an Array, starting at a particular index.
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <param name="array">The destination array</param>
/// <param name="arrayIndex">Index parameter</param>
/// <code>
/// <summary>
/// Remove the given key value pair from the query
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <param name="item">The key value pair to remove</param>
/// <returns>True if operation is successful. Otherwise, false</returns>
+ /// <feature>http://tizen.org/feature/iot.ocf</feature>
/// <seealso cref="Add()"/>
+ /// <exception cref="ArgumentException">Thrown when there is an invalid parameter</exception>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// query.Add(new KeyValuePair<string, string>("key1", "value1"));
/// <summary>
/// Get the enumerator to query collection
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <returns>Enumerator to query pairs</returns>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// <summary>
/// Get the enumerator to query collection
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <returns>Enumerator to query pairs</returns>
/// <code>
/// ResourceQuery query = new ResourceQuery();
/// <summary>
/// Releases any unmanaged resources used by this object.
/// </summary>
+ /// <since_tizen>3</since_tizen>
+ /// <feature>http://tizen.org/feature/iot.ocf</feature>
public void Dispose()
{
Dispose(true);
/// <summary>
/// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
/// </summary>
+ /// <since_tizen>3</since_tizen>
/// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
+ /// <feature>http://tizen.org/feature/iot.ocf</feature>
protected virtual void Dispose(bool disposing)
{
if (_disposed)