Show / Hide Table of Contents

    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
    Object
    ResourceQuery
    Implements
    IDictionary<String, String>
    ICollection<KeyValuePair<String, String>>
    IEnumerable<KeyValuePair<String, String>>
    IEnumerable
    IDisposable

    Constructors

    View Source

    ResourceQuery()

    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
    Add(String, String)
    Remove(String)
    API Level: 3
    Feature: http://tizen.org/feature/iot.ocf

    Properties

    View Source

    Count

    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 Source

    Interface

    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 Source

    IsReadOnly

    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 Source

    Item[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 Source

    Keys

    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 Source

    Type

    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 Source

    Values

    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 Source

    Add(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
    Remove(KeyValuePair<String, String>)
    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
    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
    Remove(String)
    API Level: 3
    Feature: http://tizen.org/feature/iot.ocf
    View Source

    Clear()

    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 Source

    Contains(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 Source

    ContainsKey(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 Source

    CopyTo(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 Source

    Dispose()

    Releases any unmanaged resources used by this object.

    Declaration
    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
    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
    protected void Finalize()
    View Source

    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 Source

    Remove(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
    Add(KeyValuePair<String, String>)
    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
    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
    Add(String, String)
    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
    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 Source

    IEnumerable.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);
        }
    API Level: 3

    Implements

    System.Collections.Generic.IDictionary<TKey,TValue>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    System.IDisposable
    • View Source
    Back to top Copyright © 2016-2020 Samsung
    Generated by DocFX