[Maps] Modify diposing routines
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / PlaceFilter.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 filter information, used in place discovery and search requests.
23     /// </summary>
24     /// <since_tizen> 3 </since_tizen>
25     public class PlaceFilter : IDisposable
26     {
27         internal Interop.PlaceFilterHandle handle;
28
29         /// <summary>
30         /// Constructs a new place filter.
31         /// </summary>
32         /// <since_tizen> 3 </since_tizen>
33         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory.</exception>
34         public PlaceFilter()
35         {
36             handle = new Interop.PlaceFilterHandle();
37         }
38
39         /// <summary>
40         /// Destroy the PlaceFilter object.
41         /// </summary>
42         ~PlaceFilter()
43         {
44             Dispose(false);
45         }
46
47         /// <summary>
48         /// Gets or sets a free-formed address string for this place filter.
49         /// </summary>
50         /// <since_tizen> 3 </since_tizen>
51         /// <remarks>Depending on maps provider which the application has selected,
52         /// it may treat <see cref="PlaceFilter.Name"/>, <see cref="PlaceFilter.Keyword"/> and <see cref="PlaceFilter.Address"/>
53         /// as the same kind of strings to search places.</remarks>
54         public string Address
55         {
56             get
57             {
58                 return handle.PlaceAddress;
59             }
60             set
61             {
62                 handle.PlaceAddress = value;
63             }
64         }
65
66         /// <summary>
67         /// Gets or sets an instance of <see cref="PlaceCategory"/> object for this place filter.
68         /// </summary>
69         /// <since_tizen> 3 </since_tizen>
70         public PlaceCategory Category
71         {
72             get
73             {
74                 return new PlaceCategory(handle.Category);
75             }
76             set
77             {
78                 handle.Category = value.handle;
79             }
80         }
81
82         /// <summary>
83         /// Gets or sets a keyword for this place filter.
84         /// </summary>
85         /// <since_tizen> 3 </since_tizen>
86         /// <remarks>Depending on maps provider which the application has selected,
87         /// it may treat <see cref="PlaceFilter.Name"/>, <see cref="PlaceFilter.Keyword"/> and <see cref="PlaceFilter.Address"/>
88         /// as the same kind of strings to search places.</remarks>
89         public string Keyword
90         {
91             get
92             {
93                 return handle.Keyword;
94             }
95             set
96             {
97                 handle.Keyword = value;
98             }
99         }
100
101         /// <summary>
102         /// Gets or sets a name for this place filter.
103         /// </summary>
104         /// <since_tizen> 3 </since_tizen>
105         /// <remarks>Depending on maps provider which the application has selected,
106         /// it may treat <see cref="PlaceFilter.Name"/>, <see cref="PlaceFilter.Keyword"/> and <see cref="PlaceFilter.Address"/>
107         /// as the same kind of strings to search places.</remarks>
108         public string Name
109         {
110             get
111             {
112                 return handle.PlaceName;
113             }
114             set
115             {
116                 handle.PlaceName = value;
117             }
118         }
119
120         #region IDisposable Support
121         private bool _disposedValue = false;
122
123         /// <summary>
124         /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
125         /// </summary>
126         /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
127         /// <since_tizen> 3 </since_tizen>
128         protected virtual void Dispose(bool disposing)
129         {
130             if (!_disposedValue)
131             {
132                 handle?.Dispose();
133                 _disposedValue = true;
134             }
135         }
136
137         /// <summary>
138         /// Releases all the resources used by this object.
139         /// </summary>
140         /// <since_tizen> 3 </since_tizen>
141         public void Dispose()
142         {
143             Dispose(true);
144             GC.SuppressFinalize(this);
145         }
146         #endregion
147     }
148 }