Class ResourceOptions

    Definition

    Namespace:
    Tizen.Network.IoTConnectivity
    Assembly:
    Tizen.Network.IoTConnectivity.dll

    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
    System.Collections.Generic.IDictionary<TKey, TValue><ushort, string>
    System.Collections.Generic.ICollection<T><System.Collections.Generic.KeyValuePair<TKey, TValue><ushort, string>>
    System.Collections.Generic.IEnumerable<T><System.Collections.Generic.KeyValuePair<TKey, TValue><ushort, string>>
    System.Collections.IEnumerable
    System.IDisposable

    Constructors

    View Source

    ResourceOptions()

    The resource options constructor.

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

    Thrown when the iotcon is not supported.

    System.OutOfMemoryException

    Thrown when there is not enough memory.

    See Also
    Add(ushort, string)
    Remove(ushort)

    Properties

    View Source

    Count

    Gets the number of options.

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

    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);
    View Source

    IsReadOnly

    Represents whether the collection is readonly.

    Declaration
    public bool IsReadOnly { get; }
    Property Value
    Type Description
    bool

    Whether the collection is readonly.

    Examples
        ResourceOptions options = new ResourceOptions();
        if (options.IsReadOnly)
            Console.WriteLine("Read only options");
    View Source

    this[ushort]

    Gets or sets the option data.

    Declaration
    public string this[ushort key] { get; set; }
    Parameters
    Type Name Description
    ushort 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]);
    View Source

    Keys

    Contains all the Option keys.

    Declaration
    public ICollection<ushort> Keys { get; }
    Property Value
    Type Description
    System.Collections.Generic.ICollection<T><ushort>

    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));
    View Source

    Values

    Contains all the Option values.

    Declaration
    public ICollection<string> Values { get; }
    Property Value
    Type Description
    System.Collections.Generic.ICollection<T><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));

    Methods

    View Source

    Add(KeyValuePair<ushort, string>)

    Adds options key and value as a key value pair.

    Declaration
    public void Add(KeyValuePair<ushort, string> item)
    Parameters
    Type Name Description
    System.Collections.Generic.KeyValuePair<TKey, TValue><ushort, string> item

    The key value pair.

    Examples
        ResourceOptions options = new ResourceOptions();
        options.Add(new KeyValuePair<ushort, string>(2050, "12345"));
    See Also
    Remove(KeyValuePair<ushort, string>)
    View Source

    Add(ushort, string)

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

    Declaration
    public void Add(ushort key, string value)
    Parameters
    Type Name Description
    ushort 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
    System.NotSupportedException

    Thrown when the iotcon is not supported.

    System.ArgumentException

    Thrown when there is an invalid parameter.

    See Also
    Remove(ushort)
    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
    System.NotSupportedException

    Thrown when the iotcon is not supported.

    View Source

    Contains(KeyValuePair<ushort, string>)

    Checks if the given option pair exists.

    Declaration
    public bool Contains(KeyValuePair<ushort, string> item)
    Parameters
    Type Name Description
    System.Collections.Generic.KeyValuePair<TKey, TValue><ushort, string> item

    The key value pair.

    Returns
    Type Description
    bool

    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");
    View Source

    ContainsKey(ushort)

    Checks whether the given key exists in Options collection.

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

    The key to look for.

    Returns
    Type Description
    bool

    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");
    View Source

    CopyTo(KeyValuePair<ushort, string>[], int)

    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
    System.Collections.Generic.KeyValuePair<TKey, TValue><ushort, string>[] array

    The destination array.

    int 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);
    View Source

    Dispose()

    Releases any unmanaged resources used by this object.

    Declaration
    public void Dispose()
    View Source

    Dispose(bool)

    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
    bool disposing

    If true, disposes any disposable objects. If false, does not dispose disposable objects.

    View Source

    ~ResourceOptions()

    Destructor of the ResourceOptions class.

    Declaration
    protected ~ResourceOptions()
    View Source

    GetEnumerator()

    Get the enumerator to options collection.

    Declaration
    public IEnumerator<KeyValuePair<ushort, string>> GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<T><System.Collections.Generic.KeyValuePair<TKey, TValue><ushort, 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);
        }
    View Source

    Remove(KeyValuePair<ushort, string>)

    Removes the given key value pair from the options.

    Declaration
    public bool Remove(KeyValuePair<ushort, string> item)
    Parameters
    Type Name Description
    System.Collections.Generic.KeyValuePair<TKey, TValue><ushort, string> item

    The key value pair to remove

    Returns
    Type Description
    bool

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

    Thrown when there is an invalid parameter

    See Also
    Add(KeyValuePair<ushort, string>)
    View Source

    Remove(ushort)

    Removes the ID and its associated data from the options.

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

    The ID of the option to delete.

    Returns
    Type Description
    bool

    True if operation is successful. Otherwise, false.

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

    Thrown when the iotcon is not supported.

    System.ArgumentException

    Thrown when there is an invalid parameter.

    See Also
    Add(ushort, string)
    View Source

    TryGetValue(ushort, out string)

    Gets the value associated with the specified key.

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

    The option ID.

    string value

    Value corresponding to option ID.

    Returns
    Type Description
    bool

    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);

    Explicit Interface Implementations

    View Source

    IEnumerable.GetEnumerator()

    Gets the enumerator to options collection.

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    System.Collections.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);
        }

    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-2024 Samsung
    Generated by DocFX