[Maps] Modify diposing routines
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / Place.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.Collections.Generic;
19
20 namespace Tizen.Maps
21 {
22     /// <summary>
23     /// Place information, used in place discovery and search requests.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     public class Place : IDisposable
27     {
28         internal Interop.PlaceHandle handle;
29
30         internal Place(Interop.PlaceHandle nativeHandle)
31         {
32             handle = nativeHandle;
33         }
34
35         /// <summary>
36         /// Destroy the Place object.
37         /// </summary>
38         ~Place()
39         {
40             Dispose(false);
41         }
42
43         /// <summary>
44         /// Gets an ID string for the place.
45         /// </summary>
46         /// <since_tizen> 3 </since_tizen>
47         public string Id
48         {
49             get
50             {
51                 return handle.Id;
52             }
53         }
54
55         /// <summary>
56         /// Gets name string for the place.
57         /// </summary>
58         /// <since_tizen> 3 </since_tizen>
59         public string Name
60         {
61             get
62             {
63                 return handle.Name;
64             }
65         }
66
67         /// <summary>
68         /// Gets a view URI for the place.
69         /// </summary>
70         /// <since_tizen> 3 </since_tizen>
71         public string Uri
72         {
73             get
74             {
75                 return handle.Uri;
76             }
77         }
78
79         /// <summary>
80         /// Gets a distance for the place from the center.
81         /// </summary>
82         /// <since_tizen> 3 </since_tizen>
83         public int Distance
84         {
85             get
86             {
87                 return handle.Distance;
88             }
89         }
90
91         /// <summary>
92         /// Gets a geographical location for the place.
93         /// </summary>
94         /// <since_tizen> 3 </since_tizen>
95         public Geocoordinates Coordinates
96         {
97             get
98             {
99                 return new Geocoordinates(handle.Coordinates);
100             }
101         }
102
103         /// <summary>
104         /// Gets an address for the place.
105         /// </summary>
106         /// <since_tizen> 3 </since_tizen>
107         public PlaceAddress Address
108         {
109             get
110             {
111                 return new PlaceAddress(handle.Address);
112             }
113         }
114
115         /// <summary>
116         /// Gets a rating for the place.
117         /// </summary>
118         /// <since_tizen> 3 </since_tizen>
119         public PlaceRating Rating
120         {
121             get
122             {
123                 return new PlaceRating(handle.Rating);
124             }
125         }
126
127         /// <summary>
128         /// Gets a supplier link for the place.
129         /// </summary>
130         /// <since_tizen> 3 </since_tizen>
131         public PlaceLink Supplier
132         {
133             get
134             {
135                 return new PlaceLink(handle.Supplier);
136             }
137         }
138
139         /// <summary>
140         /// Gets a related link for the place.
141         /// </summary>
142         /// <since_tizen> 3 </since_tizen>
143         public PlaceLink Related
144         {
145             get
146             {
147                 return new PlaceLink(handle.Related);
148             }
149         }
150
151         /// <summary>
152         /// Gets all the properties attached to this place.
153         /// </summary>
154         /// <since_tizen> 3 </since_tizen>
155         public IDictionary<string, string> Properties
156         {
157             get
158             {
159                 var properties = new Dictionary<string, string>();
160                 handle.ForeachProperty((key, value) => properties[key] = value);
161                 return properties;
162             }
163         }
164
165         /// <summary>
166         /// Gets all the categories attached to this place.
167         /// </summary>
168         /// <since_tizen> 3 </since_tizen>
169         public IEnumerable<PlaceCategory> Categories
170         {
171             get
172             {
173                 var categories = new List<PlaceCategory>();
174                 handle.ForeachCategory((categoryHandle) => categories.Add(new PlaceCategory(categoryHandle)));
175                 return categories;
176             }
177         }
178
179         /// <summary>
180         /// Gets all the attributes attached to this place.
181         /// </summary>
182         /// <since_tizen> 3 </since_tizen>
183         public IEnumerable<PlaceAttribute> Attributes
184         {
185             get
186             {
187                 var attributes = new List<PlaceAttribute>();
188                 handle.ForeachAttribute((attributeHandle) => attributes.Add(new PlaceAttribute(attributeHandle)));
189                 return attributes;
190             }
191         }
192
193         /// <summary>
194         /// Gets all the contacts attached to this place.
195         /// </summary>
196         /// <since_tizen> 3 </since_tizen>
197         public IEnumerable<PlaceContact> Contacts
198         {
199             get
200             {
201                 var contacts = new List<PlaceContact>();
202                 handle.ForeachContact((contactHandle) => contacts.Add(new PlaceContact(contactHandle)));
203                 return contacts;
204             }
205         }
206
207         /// <summary>
208         /// Gets all the editorials attached to this place.
209         /// </summary>
210         /// <since_tizen> 3 </since_tizen>
211         public IEnumerable<PlaceEditorial> Editorials
212         {
213             get
214             {
215                 var editorials = new List<PlaceEditorial>();
216                 handle.ForeachEditorial((editorialHandle) => editorials.Add(new PlaceEditorial(editorialHandle)));
217                 return editorials;
218             }
219         }
220
221         /// <summary>
222         /// Gets all the images attached to this place.
223         /// </summary>
224         /// <since_tizen> 3 </since_tizen>
225         public IEnumerable<PlaceImage> Images
226         {
227             get
228             {
229                 var images = new List<PlaceImage>();
230                 handle.ForeachImage((imageHandle) => images.Add(new PlaceImage(imageHandle)));
231                 return images;
232             }
233         }
234
235         /// <summary>
236         /// Gets all the reviews attached to this place.
237         /// </summary>
238         /// <since_tizen> 3 </since_tizen>
239         public IEnumerable<PlaceReview> Reviews
240         {
241             get
242             {
243                 var reviews = new List<PlaceReview>();
244                 handle.ForeachReview((reviewHandle) => reviews.Add(new PlaceReview(reviewHandle)));
245                 return reviews;
246             }
247         }
248
249         #region IDisposable Support
250         private bool _disposedValue = false;
251
252         /// <summary>
253         /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
254         /// </summary>
255         /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
256         protected virtual void Dispose(bool disposing)
257         {
258             if (!_disposedValue)
259             {
260                 handle?.Dispose();
261                 _disposedValue = true;
262             }
263         }
264
265         /// <summary>
266         /// Releases all the resources used by this object.
267         /// </summary>
268         /// <since_tizen> 3 </since_tizen>
269         public void Dispose()
270         {
271             Dispose(true);
272             GC.SuppressFinalize(this);
273         }
274         #endregion
275     }
276 }