Add 'GC.SuppressFinalize(this)' on Dispose()
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / Route.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
18 using System;
19 using System.Collections.Generic;
20
21 namespace Tizen.Maps
22 {
23     /// <summary>
24     /// Route information, used in Route Search requests
25     /// </summary>
26     public class Route : IDisposable
27     {
28         internal Interop.RouteHandle handle;
29
30         internal Route(Interop.RouteHandle nativeHandle)
31         {
32             handle = nativeHandle;
33         }
34
35         /// <summary>
36         /// Destination coordinates for this route
37         /// </summary>
38         public Geocoordinates Destination
39         {
40             get
41             {
42                 return new Geocoordinates(handle.Destination);
43             }
44         }
45
46         /// <summary>
47         /// Total distance for this route
48         /// </summary>
49         public double Distance
50         {
51             get
52             {
53                 return handle.Distance;
54             }
55         }
56
57         /// <summary>
58         /// Total duration to cover this route
59         /// </summary>
60         public double Duration
61         {
62             get
63             {
64                 return handle.Duration;
65             }
66         }
67
68         public string Id
69         {
70             get
71             {
72                 return handle.Id;
73             }
74         }
75
76         /// <summary>
77         /// Transport Mode for this route
78         /// </summary>
79         public TransportMode Mode
80         {
81             get
82             {
83                 return (TransportMode)handle.TransportMode;
84             }
85         }
86
87         /// <summary>
88         /// Origin coordinates for this route
89         /// </summary>
90         public Geocoordinates Origin
91         {
92             get
93             {
94                 return new Geocoordinates(handle.Origin);
95             }
96         }
97
98         /// <summary>
99         /// Coordinates list for this route
100         /// </summary>
101         public IEnumerable<Geocoordinates> Path
102         {
103             get
104             {
105                 var path = new List<Geocoordinates>();
106                 handle.ForeachPath(coordinateHandle => path.Add(new Geocoordinates(coordinateHandle)));
107                 return path;
108             }
109         }
110
111         /// <summary>
112         /// Segment list for this route
113         /// </summary>
114         public IEnumerable<RouteSegment> Segments
115         {
116             get
117             {
118                 var segments = new List<RouteSegment>();
119                 handle.ForeachSegment(segmentHandle => segments.Add(new RouteSegment(segmentHandle)));
120                 return segments;
121             }
122         }
123
124         /// <summary>
125         /// Distance unit for this route
126         /// </summary>
127         public DistanceUnit Unit
128         {
129             get
130             {
131                 return (DistanceUnit)handle.Unit;
132             }
133         }
134
135         /// <summary>
136         /// Bounding area for this route
137         /// </summary>
138         private Area BoundingBox
139         {
140             get
141             {
142                 return new Area(handle.BoundingBox);
143             }
144         }
145
146         #region IDisposable Support
147         private bool _disposedValue = false;
148
149         protected virtual void Dispose(bool disposing)
150         {
151             if (!_disposedValue)
152             {
153                 handle.Dispose();
154                 _disposedValue = true;
155             }
156         }
157
158         public void Dispose()
159         {
160             Dispose(true);
161             GC.SuppressFinalize(this);
162         }
163         #endregion
164     }
165 }