Show / Hide Table of Contents

    Class LiteResource

    Definition

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

    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
    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
    API Level: 3
    Privilege Level: public
    Privilege: http://tizen.org/privilege/internet
    Feature: http://tizen.org/feature/iot.ocf
    Precondition: IoTConnectivityServerManager.Initialize() should be called to initialize.

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

    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
    Boolean

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

    Implements

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