Show / Hide Table of Contents

    Class ResourceOptions

    Definition

    Namespace:
    Tizen.Network.IoTConnectivity
    Assembly:
    Tizen.Network.IoTConnectivity.dll
    API Level:
    3

    This class represents resource options. It provides APIs to manage them.

    The iotcon options API provides methods for managing vendor specific options of coap packet.

    See more about coap packet in http://tools.ietf.org/html/rfc7252.

    public class ResourceOptions : IDictionary<ushort, string>, ICollection<KeyValuePair<ushort, string>>, IEnumerable<KeyValuePair<ushort, string>>, IEnumerable, IDisposable
    Inheritance
    Object
    ResourceOptions
    Implements
    IDictionary<UInt16, String>
    ICollection<KeyValuePair<UInt16, String>>
    IEnumerable<KeyValuePair<UInt16, String>>
    IEnumerable
    IDisposable

    Constructors

    View Source

    ResourceOptions()

    The resource options constructor.

    Declaration
    public ResourceOptions()
    Examples
        ResourceOptions options = new ResourceOptions();
    Exceptions
    Type Condition
    NotSupportedException

    Thrown when the iotcon is not supported.

    OutOfMemoryException

    Thrown when there is not enough memory.

    See Also
    Add(UInt16, String)
    Remove(UInt16)
    API Level: 3
    Feature: http://tizen.org/feature/iot.ocf

    Properties

    View Source

    Count

    Gets the number of options.

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

    The number of options.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(2050, "sample-data");
        options.Add(2055, "sample value");
        var count = options.Count;
        Console.WriteLine("There are {0} keys in the options object", count);
    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
        ResourceOptions options = new ResourceOptions();
        if (options.IsReadOnly)
            Console.WriteLine("Read only options");
    API Level: 3
    View Source

    Item[UInt16]

    Gets or sets the option data.

    Declaration
    public string this[ushort key] { get; set; }
    Parameters
    Type Name Description
    UInt16 key

    The option ID to get or set.

    Property Value
    Type Description
    String

    The option data.

    Examples
        ResourceOptions options = new ResourceOptions();
        options[2055] = "sample-data";
        Console.WriteLine("Option has : {0}", options[2055]);
    API Level: 3
    View Source

    Keys

    Contains all the Option keys.

    Declaration
    public ICollection<ushort> Keys { get; }
    Property Value
    Type Description
    ICollection<UInt16>

    All the Option keys.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(2050, "sample-data");
        options.Add(2055, "sample value");
        var keys = options.Keys;
        Console.WriteLine("Resource options contains keys {0} and {1}", keys.ElementAt(0), keys.ElementAt(1));
    API Level: 3
    View Source

    Values

    Contains all the Option values.

    Declaration
    public ICollection<string> Values { get; }
    Property Value
    Type Description
    ICollection<String>

    All the Option values.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(2050, "sample-data");
        options.Add(2055, "sample value");
        var values = options.Values;
        Console.WriteLine("Resource options contains values {0} and {1}", values.ElementAt(0), values.ElementAt(1));
    API Level: 3

    Methods

    View Source

    Add(KeyValuePair<UInt16, String>)

    Adds options key and value as a key value pair.

    Declaration
    public void Add(KeyValuePair<ushort, string> item)
    Parameters
    Type Name Description
    KeyValuePair<UInt16, String> item

    The key value pair.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
    See Also
    Remove(KeyValuePair<UInt16, String>)
    API Level: 3
    Feature: http://tizen.org/feature/iot.ocf
    View Source

    Add(UInt16, String)

    Adds a new ID and a correspoding data into the options.

    Declaration
    public void Add(ushort key, string value)
    Parameters
    Type Name Description
    UInt16 key

    The ID of the option to insert.

    String value

    The string data to insert into the options.

    Remarks

    ResourceOptions can have up to 2 options.

    key is always situated between 2048 and 3000.

    Length of option data is less than or equal to 15.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(2050, "sample-data");
    Exceptions
    Type Condition
    NotSupportedException

    Thrown when the iotcon is not supported.

    ArgumentException

    Thrown when there is an invalid parameter.

    See Also
    Remove(UInt16)
    API Level: 3
    Feature: http://tizen.org/feature/iot.ocf
    View Source

    Clear()

    Clears the Options collection.

    Declaration
    public void Clear()
    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(2050, "12345");
        options.Add(2055, "sample");
        options.Clear();
    Exceptions
    Type Condition
    NotSupportedException

    Thrown when the iotcon is not supported.

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

    Contains(KeyValuePair<UInt16, String>)

    Checks if the given option pair exists.

    Declaration
    public bool Contains(KeyValuePair<ushort, string> item)
    Parameters
    Type Name Description
    KeyValuePair<UInt16, String> item

    The key value pair.

    Returns
    Type Description
    Boolean

    True if exists. Otherwise, false.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
        var isPresent = options.Contains(new KeyValuePair<ushort, string>(2050, "12345"));
        if (isPresent)
            Console.WriteLine("Key value pair is present");
    API Level: 3
    View Source

    ContainsKey(UInt16)

    Checks whether the given key exists in Options collection.

    Declaration
    public bool ContainsKey(ushort key)
    Parameters
    Type Name Description
    UInt16 key

    The key to look for.

    Returns
    Type Description
    Boolean

    true if exists. Otherwise, false.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(2050, "sample-data");
        if (options.ContainsKey(2050))
            Console.WriteLine("options conatins key : 2050");
    API Level: 3
    View Source

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

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

    Declaration
    public void CopyTo(KeyValuePair<ushort, string>[] array, int arrayIndex)
    Parameters
    Type Name Description
    KeyValuePair<UInt16, String>[] array

    The destination array.

    Int32 arrayIndex

    Index parameter.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
        KeyValuePair<ushort, string>[] dest = new KeyValuePair<ushort, string>[options.Count];
        options.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 ResourceOptions class.

    Declaration
    protected void Finalize()
    View Source

    GetEnumerator()

    Get the enumerator to options collection.

    Declaration
    public IEnumerator<KeyValuePair<ushort, string>> GetEnumerator()
    Returns
    Type Description
    IEnumerator<KeyValuePair<UInt16, String>>

    Enumerator to option pairs.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(new KeyValuePair<ushort, string>(2050, "sample1"));
        options.Add(new KeyValuePair<ushort, string>(2055, "sample2"));
        foreach (KeyValuePair<string, object> pair in options)
        {
            Console.WriteLine("key : {0}, value : {1}", pair.Key, pair.Value);
        }
    API Level: 3
    View Source

    Remove(KeyValuePair<UInt16, String>)

    Removes the given key value pair from the options.

    Declaration
    public bool Remove(KeyValuePair<ushort, string> item)
    Parameters
    Type Name Description
    KeyValuePair<UInt16, String> item

    The key value pair to remove

    Returns
    Type Description
    Boolean

    True if operation is successful. Otherwise, false

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
        var result = options.Remove(new KeyValuePair<ushort, string>(2050, "12345"));
    Exceptions
    Type Condition
    ArgumentException

    Thrown when there is an invalid parameter

    See Also
    Add(KeyValuePair<UInt16, String>)
    API Level: 3
    Feature: http://tizen.org/feature/iot.ocf
    View Source

    Remove(UInt16)

    Removes the ID and its associated data from the options.

    Declaration
    public bool Remove(ushort key)
    Parameters
    Type Name Description
    UInt16 key

    The ID of the option to delete.

    Returns
    Type Description
    Boolean

    True if operation is successful. Otherwise, false.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(2050, "12345");
        var result = options.Remove(2050);
    Exceptions
    Type Condition
    NotSupportedException

    Thrown when the iotcon is not supported.

    ArgumentException

    Thrown when there is an invalid parameter.

    See Also
    Add(UInt16, String)
    API Level: 3
    Feature: http://tizen.org/feature/iot.ocf
    View Source

    TryGetValue(UInt16, out String)

    Gets the value associated with the specified key.

    Declaration
    public bool TryGetValue(ushort key, out string value)
    Parameters
    Type Name Description
    UInt16 key

    The option ID.

    String value

    Value corresponding to option ID.

    Returns
    Type Description
    Boolean

    True if the key exists, false otherwise.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(2050, "12345");
        string value;
        var isPresent = options.TryGetValue(2050, out value);
        if (isPresent)
            Console.WriteLine("value : {0}", value);
    API Level: 3

    Explicit Interface Implementations

    View Source

    IEnumerable.GetEnumerator()

    Gets the enumerator to options collection.

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    Enumerator to option pairs.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(new KeyValuePair<ushort, string>(2050, "sample1"));
        options.Add(new KeyValuePair<ushort, string>(2055, "sample2"));
        foreach (KeyValuePair<string, object> pair in options)
        {
            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