Class LiteResource

    Definition

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

    This class represents a lite resource. It provides APIs to encapsulate resources. This class is accessed by using a constructor to create a new instance of this object.

    public class LiteResource : Resource, IDisposable
    Inheritance
    object
    Resource
    LiteResource
    Implements
    System.IDisposable

    Constructors

    View Source

    LiteResource(string, ResourceTypes, ResourcePolicy, Attributes)

    The LiteResource constructor.

    Declaration
    public LiteResource(string uri, ResourceTypes types, ResourcePolicy policy, Attributes attribs = null)
    Parameters
    Type Name Description
    string uri

    The uri path of the lite resource.

    ResourceTypes types

    The type of the resource.

    ResourcePolicy policy

    Policy of the resource.

    Attributes attribs

    Optional attributes of the resource.

    Remarks

    Creates a lite resource, which can then be registered in server using RegisterResource(Resource).

    When client requests some operations, it sends a response to client automatically.

    uri length must be less than 128.

    Examples
        List<string> list = new List<string>() { "org.tizen.light" };
        Attributes attributes = new Attributes() {
            { "state", "ON" }
        };
        LiteResource res = new LiteResource("/light/1", new ResourceTypes(list), ResourcePolicy.Discoverable, attributes);
    See Also
    ResourceTypes
    ResourcePolicy
    Attributes

    Properties

    View Source

    Attributes

    Gets or sets the attributes of the lite resource.

    Declaration
    public Attributes Attributes { get; set; }
    Property Value
    Type Description
    Attributes

    The attributes of the lite resource.

    Examples
        List<string> list = new List<string>() { "org.tizen.light" };
        LiteResource res = new LiteResource("/light/1", new ResourceTypes(list), ResourcePolicy.Discoverable);
        Attributes attributes = new Attributes() {
            { "state", "ON" }
        };
        res.Attributes = newAttributes;
        foreach (KeyValuePair<string, object> pair in res.Attributes)
        {
            Console.WriteLine("key : {0}, value : {1}", pair.Key, pair.Value);
        }

    Methods

    View Source

    OnPost(Attributes)

    Decides whether to accept or reject a post request.

    Declaration
    protected virtual bool OnPost(Attributes attribs)
    Parameters
    Type Name Description
    Attributes attribs

    The new attributes of the lite resource.

    Returns
    Type Description
    bool

    true to accept post request, false to reject it.

    Remarks

    Child classes of this class can override this method to accept or reject post request.

    Examples
        public class MyLightResource : LiteResource
        {
            protected override bool OnPost(Attributes attributes)
            {
                object newAttributes;
                attributes.TryGetValue("LIGHT_ATTRIBUTE", out newAttributes);
                if((int)newAttributes == 1)
                    return true;
                return false;
            }
        }

    Implements

    System.IDisposable
    • View Source
    Back to top Copyright © 2016-2024 Samsung
    Generated by DocFX