[Maps] Modify diposing routines
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / Area.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     /// The class representing a geographical area.
23     /// </summary>
24     /// <since_tizen> 3 </since_tizen>
25     public class Area : IDisposable
26     {
27         internal Interop.AreaHandle handle;
28
29         /// <summary>
30         /// Constructs a rectangular area.
31         /// </summary>
32         /// <since_tizen> 3 </since_tizen>
33         /// <param name="topLeft">Top-left coordinates of the area.</param>
34         /// <param name="bottomRight">Bottom-left coordinates of the area.</param>
35         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
36         /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
37         /// <exception cref="System.InvalidOperationException">Thrown when a native operation fails to allocate memory.</exception>
38         public Area(Geocoordinates topLeft, Geocoordinates bottomRight)
39         {
40             handle = new Interop.AreaHandle(topLeft?.handle, bottomRight?.handle);
41         }
42
43         /// <summary>
44         /// Constructs a circular area.
45         /// </summary>
46         /// <since_tizen> 3 </since_tizen>
47         /// <param name="center">Coordinates for center of the area.</param>
48         /// <param name="radius">Radius of the area.</param>
49         /// <exception cref="System.NotSupportedException">Thrown when the required feature is not supported.</exception>
50         /// <exception cref="System.ArgumentException">Thrown when input coordinates are invalid.</exception>
51         /// <exception cref="System.InvalidOperationException">Thrown when a native operation fails to allocate memory.</exception>
52         public Area(Geocoordinates center, double radius)
53         {
54             handle = new Interop.AreaHandle(center?.handle, radius);
55         }
56
57         internal Area(Interop.AreaHandle nativeHandle)
58         {
59             handle = nativeHandle;
60         }
61
62         /// <summary>
63         /// Destroy the Area object.
64         /// </summary>
65         ~Area()
66         {
67             Dispose(false);
68         }
69
70         #region IDisposable Support
71         private bool _disposedValue = false;
72
73         /// <summary>
74         /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
75         /// </summary>
76         /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
77         /// <since_tizen> 3 </since_tizen>
78         protected virtual void Dispose(bool disposing)
79         {
80             if (!_disposedValue)
81             {
82                 handle?.Dispose();
83                 _disposedValue = true;
84             }
85         }
86
87         /// <summary>
88         /// Releases all the resources used by this object.
89         /// </summary>
90         /// <since_tizen> 3 </since_tizen>
91         public void Dispose()
92         {
93             Dispose(true);
94             GC.SuppressFinalize(this);
95         }
96         #endregion
97     }
98 }