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.
C#Copypublic class LiteResource : Resource, IDisposable
- Inheritance
- Implements
-
System.IDisposable
Constructors
View Source
LiteResource(String, ResourceTypes, ResourcePolicy, Attributes)
The LiteResource constructor.
Declaration
C#Copypublic LiteResource(string uri, ResourceTypes types, ResourcePolicy policy, Attributes attribs = null)
Parameters
Type | Name | Description |
---|---|---|
System.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
CopyList<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);
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
Declaration
C#Copypublic Attributes Attributes { get; set; }
Property Value
Type | Description |
---|---|
Attributes | The attributes of the lite resource. |
Examples
CopyList<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
Declaration
C#Copyprotected virtual bool OnPost(Attributes attribs)
Parameters
Type | Name | Description |
---|---|---|
Attributes | attribs | The new attributes of the lite resource. |
Returns
Type | Description |
---|---|
System.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
Copypublic 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