53bb53d2f938d9491915fec8758248f2484801ee
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.IoTConnectivity / Tizen.Network.IoTConnectivity / Request.cs
1  /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 using System;
19
20 namespace Tizen.Network.IoTConnectivity
21 {
22     /// <summary>
23     /// Class respresenting request to a resource.
24     /// It provides APIs to manage client's request.
25     /// </summary>
26     public class Request : IDisposable
27     {
28         private bool _disposed = false;
29
30         internal Request()
31         {
32         }
33
34         /// <summary>
35         /// Destructor of the Request class.
36         /// </summary>
37         ~Request()
38         {
39             Dispose(false);
40         }
41
42         /// <summary>
43         /// The host address of the request
44         /// </summary>
45         public string HostAddress { get; internal set; }
46
47         /// <summary>
48         /// The representation of the request
49         /// </summary>
50         public Representation Representation { get; internal set; }
51
52         /// <summary>
53         /// The query of the request
54         /// </summary>
55         public ResourceQuery Query { get; internal set; }
56
57         /// <summary>
58         /// The options related to the request
59         /// </summary>
60         public ResourceOptions Options { get; internal set; }
61
62         /// <summary>
63         /// Releases any unmanaged resources used by this object.
64         /// </summary>
65         public void Dispose()
66         {
67             Dispose(true);
68             GC.SuppressFinalize(this);
69         }
70
71         /// <summary>
72         /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
73         /// </summary>
74         /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
75         protected virtual void Dispose(bool disposing)
76         {
77             if (_disposed)
78                 return;
79
80             if (disposing)
81             {
82                 Representation?.Dispose();
83                 Query?.Dispose();
84                 Options?.Dispose();
85             }
86
87             _disposed = true;
88         }
89     }
90 }