[Maps] Modify diposing routines
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / PlaceCategory.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 using System;
18
19 namespace Tizen.Maps
20 {
21     /// <summary>
22     /// Place category information, used in place discovery and search requests.
23     /// </summary>
24     /// <since_tizen> 3 </since_tizen>
25     public class PlaceCategory : IDisposable
26     {
27         internal Interop.PlaceCategoryHandle handle;
28
29         /// <summary>
30         /// Constructs a search category object.
31         /// </summary>
32         /// <since_tizen> 3 </since_tizen>
33         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory.</exception>
34         public PlaceCategory()
35         {
36             handle = new Interop.PlaceCategoryHandle();
37         }
38
39         internal PlaceCategory(Interop.PlaceCategoryHandle nativeHandle)
40         {
41             handle = nativeHandle;
42         }
43
44         /// <summary>
45         /// Destroy the PlaceCategory object.
46         /// </summary>
47         ~PlaceCategory()
48         {
49             Dispose(false);
50         }
51
52         /// <summary>
53         /// Gets or sets an ID for this category.
54         /// </summary>
55         /// <since_tizen> 3 </since_tizen>
56         public string Id
57         {
58             get { return handle.Id; }
59             set { handle.Id = value; }
60         }
61
62         /// <summary>
63         /// Gets or sets a name for this category.
64         /// </summary>
65         /// <since_tizen> 3 </since_tizen>
66         public string Name
67         {
68             get { return handle.Name; }
69             set { handle.Name = value; }
70         }
71
72         /// <summary>
73         /// Gets or sets a URL for this category.
74         /// </summary>
75         /// <since_tizen> 3 </since_tizen>
76         public string Url
77         {
78             get { return handle.Url; }
79             set { handle.Url = value; }
80         }
81
82         /// <summary>
83         /// Returns a string that represents this object.
84         /// </summary>
85         /// <since_tizen> 3 </since_tizen>
86         /// <returns>Returns a string which presents this object.</returns>
87         public override string ToString()
88         {
89             return $"{Name}";
90         }
91
92         #region IDisposable Support
93         private bool _disposedValue = false;
94
95         /// <summary>
96         /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
97         /// </summary>
98         /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
99         /// <since_tizen> 3 </since_tizen>
100         protected virtual void Dispose(bool disposing)
101         {
102             if (!_disposedValue)
103             {
104                 handle?.Dispose();
105                 _disposedValue = true;
106             }
107         }
108
109         /// <summary>
110         /// Releases all the resources used by this object.
111         /// </summary>
112         /// <since_tizen> 3 </since_tizen>
113         public void Dispose()
114         {
115             Dispose(true);
116             GC.SuppressFinalize(this);
117         }
118         #endregion
119     }
120 }