[Maps] Modify diposing routines
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / PlaceAddress.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 using System.ComponentModel;
19
20 namespace Tizen.Maps
21 {
22     /// <summary>
23     /// Address information for the map point used in geocode and reverse geocode requests.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     public class PlaceAddress : IDisposable
27     {
28         internal Interop.AddressHandle handle;
29
30         /// <summary>
31         /// Constructs a map address object.
32         /// </summary>
33         /// <since_tizen> 3 </since_tizen>
34         /// <exception cref="System.InvalidOperationException">Thrown when native operation failed to allocate memory.</exception>
35         public PlaceAddress()
36         {
37             handle = new Interop.AddressHandle();
38         }
39
40         internal PlaceAddress(Interop.AddressHandle nativeHandle)
41         {
42             handle = nativeHandle;
43         }
44
45         /// <summary>
46         /// Destroy the PlaceAddress object.
47         /// </summary>
48         ~PlaceAddress()
49         {
50             Dispose(false);
51         }
52
53         /// <summary>
54         /// Gets a building number for this address.
55         /// </summary>
56         /// <since_tizen> 3 </since_tizen>
57         public string Building
58         {
59             get
60             {
61                 return handle.Building;
62             }
63             set
64             {
65                 handle.Building = value;
66             }
67         }
68
69         /// <summary>
70         /// Gets a city name for this address.
71         /// </summary>
72         /// <since_tizen> 3 </since_tizen>
73         public string City
74         {
75             get
76             {
77                 return handle.City;
78             }
79             set
80             {
81                 handle.City = value;
82             }
83         }
84
85         /// <summary>
86         /// Gets a country name for this address.
87         /// </summary>
88         /// <since_tizen> 3 </since_tizen>
89         public string Country
90         {
91             get
92             {
93                 return handle.Country;
94             }
95             set
96             {
97                 handle.Country = value;
98             }
99         }
100
101         /// <summary>
102         /// Gets a country code for this address.
103         /// </summary>
104         /// <since_tizen> 3 </since_tizen>
105         public string CountryCode
106         {
107             get
108             {
109                 return handle.CountryCode;
110             }
111             set
112             {
113                 handle.CountryCode = value;
114             }
115         }
116
117         /// <summary>
118         /// Gets a county for this address.
119         /// </summary>
120         /// <since_tizen> 3 </since_tizen>
121         public string County
122         {
123             get
124             {
125                 return handle.County;
126             }
127             set
128             {
129                 handle.County = value;
130             }
131         }
132
133         /// <summary>
134         /// Gets a district name for this address.
135         /// </summary>
136         /// <since_tizen> 3 </since_tizen>
137         public string District
138         {
139             get
140             {
141                 return handle.District;
142             }
143             set
144             {
145                 handle.District = value;
146             }
147         }
148
149         /// <summary>
150         /// Gets a free text associated with this address.
151         /// </summary>
152         /// <since_tizen> 4 </since_tizen>
153         public string FreeText
154         {
155             get
156             {
157                 return handle.FreeText;
158             }
159             set
160             {
161                 handle.FreeText = value;
162             }
163         }
164
165         /// <summary>
166         /// Gets a postal code for this address.
167         /// </summary>
168         /// <since_tizen> 3 </since_tizen>
169         public string PostalCode
170         {
171             get
172             {
173                 return handle.PostalCode;
174             }
175             set
176             {
177                 handle.PostalCode = value;
178             }
179         }
180
181         /// <summary>
182         /// Gets a state name for this address.
183         /// </summary>
184         /// <since_tizen> 3 </since_tizen>
185         public string State
186         {
187             get
188             {
189                 return handle.State;
190             }
191             set
192             {
193                 handle.State = value;
194             }
195         }
196
197         /// <summary>
198         /// Gets a street name for this address.
199         /// </summary>
200         /// <since_tizen> 3 </since_tizen>
201         public string Street
202         {
203             get
204             {
205                 return handle.Street;
206             }
207             set
208             {
209                 handle.Street = value;
210             }
211         }
212
213         /// <summary>
214         /// Returns a string that represents this object.
215         /// </summary>
216         /// <since_tizen> 3 </since_tizen>
217         /// <returns>Returns a string which presents this object.</returns>
218         public override string ToString()
219         {
220             return $"{FreeText}";
221         }
222
223         #region IDisposable Support
224         private bool _disposedValue = false;
225
226         /// <summary>
227         /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
228         /// </summary>
229         /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
230         /// <since_tizen> 3 </since_tizen>
231         protected virtual void Dispose(bool disposing)
232         {
233             if (!_disposedValue)
234             {
235                 handle?.Dispose();
236                 _disposedValue = true;
237             }
238         }
239
240         /// <summary>
241         /// Releases all the resources used by this object.
242         /// </summary>
243         /// <since_tizen> 3 </since_tizen>
244         public void Dispose()
245         {
246             Dispose(true);
247             GC.SuppressFinalize(this);
248         }
249         #endregion
250     }
251 }