Merge "fixed for Visual Studio 2017" into tizen
[platform/core/csapi/tizenfx.git] / src / Tizen.Maps / Tizen.Maps / SearchPreference.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     /// Preferences for route search requests
24     /// </summary>
25     public class SearchPreference : IGeocodePreference, IPlaceSearchPreference, IRouteSearchPreference, IDisposable
26     {
27         internal Interop.PreferenceHandle handle;
28         private IReadOnlyDictionary<string, string> _properties = new Dictionary<string, string>();
29
30         /// <summary>
31         /// Constructors a new search preference.
32         /// </summary>
33         public SearchPreference()
34         {
35             handle = new Interop.PreferenceHandle();
36         }
37
38         /// <summary>
39         /// Constructors a new search preference.
40         /// </summary>
41         internal SearchPreference(Interop.PreferenceHandle nativeHandle)
42         {
43             handle = nativeHandle;
44         }
45
46         /// <summary>
47         /// Gets or sets preferred language.
48         /// </summary>
49         /// <remarks>Language should be specified as an ISO 3166 alpha-2 two letter country-code
50         /// followed by ISO 639-1 for the two-letter language code.<br/>e.g. "ko-KR", "en-US".</remarks>
51         public string Language
52         {
53             get
54             {
55                 return handle.Language;
56             }
57             set
58             {
59                 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
60                 handle.Language = value;
61             }
62         }
63
64         /// <summary>
65         /// Gets or sets the maximum result count for each service request.
66         /// </summary>
67         /// <remarks>Setting negative value will not have any effect on MaxResults value</remarks>
68         public int MaxResults
69         {
70             get
71             {
72                 return handle.MaxResult;
73             }
74             set
75             {
76                 Log.Info(string.Format("MaxResult is changed from {0} to {1}", handle.MaxResult, value));
77                 handle.MaxResult = value;
78             }
79         }
80
81         /// <summary>
82         /// Gets or sets distance unit.
83         /// </summary>
84         public DistanceUnit Unit
85         {
86             get
87             {
88                 return (DistanceUnit)handle.Unit;
89             }
90             set
91             {
92                 Log.Info(string.Format("Unit is changed from {0} to {1}", handle.Unit, value));
93                 handle.Unit = (Interop.DistanceUnit)value;
94             }
95         }
96
97         /// <summary>
98         /// Gets or sets preferred country.
99         /// </summary>
100         public string CountryCode
101         {
102             get
103             {
104                 return handle.CountryCode;
105             }
106             set
107             {
108                 Log.Info(string.Format("CountryCode is changed from {0} to {1}", handle.CountryCode, value));
109                 handle.CountryCode = value;
110             }
111         }
112
113         /// <summary>
114         /// Gets or sets search properties as key value pair.
115         /// </summary>
116         public IReadOnlyDictionary<string, string> Properties
117         {
118             get
119             {
120                 return _properties;
121             }
122             set
123             {
124                 Log.Info(string.Format("Properties is changed from {0} to {1}", Properties.ToString(), value.ToString()));
125                 _properties = value;
126             }
127         }
128
129         /// <summary>
130         /// Gets or sets route optimization.
131         /// </summary>
132         public RouteOptimization Optimization
133         {
134             get
135             {
136                 return (RouteOptimization)handle.Optimization;
137             }
138             set
139             {
140                 Log.Info(string.Format("Optimization is changed from {0} to {1}", handle.Optimization, value));
141                 handle.Optimization = (Interop.RouteOptimization)value;
142             }
143         }
144
145         /// <summary>
146         /// Gets or sets route transport mode.
147         /// </summary>
148         public TransportMode Mode
149         {
150             get
151             {
152                 return (TransportMode)handle.TransportMode;
153             }
154             set
155             {
156                 Log.Info(string.Format("TransportMode is changed from {0} to {1}", handle.TransportMode, value));
157                 handle.TransportMode = (Interop.RouteTransportMode)value;
158             }
159         }
160
161         /// <summary>
162         /// Gets or sets route feature weight.
163         /// </summary>
164         public RouteFeatureWeight RouteFeatureWeight
165         {
166             get
167             {
168                 return (RouteFeatureWeight)handle.FeatureWeight;
169             }
170             set
171             {
172                 Log.Info(string.Format("RouteFeatureWeight is changed from {0} to {1}", handle.FeatureWeight, value));
173                 handle.FeatureWeight = (Interop.RouteFeatureWeight)value;
174             }
175         }
176
177         /// <summary>
178         /// Gets or sets route feature.
179         /// </summary>
180         public RouteFeature RouteFeature
181         {
182             get
183             {
184                 return (RouteFeature)handle.Feature;
185             }
186             set
187             {
188                 Log.Info(string.Format("RouteFeature is changed from {0} to {1}", handle.Feature, value));
189                 handle.Feature = (Interop.RouteRequestFeature)value;
190             }
191         }
192
193         /// <summary>
194         /// Gets or sets if searching for alternative routes is enabled.
195         /// </summary>
196         public bool SearchAlternativeRoutes
197         {
198             get
199             {
200                 return handle.AlternativesEnabled;
201             }
202             set
203             {
204                 Log.Info(string.Format("SearchAlternativeRoutes is {0}", (value ? "enabled" : "disabled")));
205                 handle.AlternativesEnabled = value;
206             }
207         }
208
209         #region IDisposable Support
210         private bool _disposedValue = false;
211
212         protected virtual void Dispose(bool disposing)
213         {
214             if (!_disposedValue)
215             {
216                 handle.Dispose();
217                 _disposedValue = true;
218             }
219         }
220
221         /// <summary>
222         /// Releases all resources used by this object.
223         /// </summary>
224         public void Dispose()
225         {
226             Dispose(true);
227             GC.SuppressFinalize(this);
228         }
229         #endregion
230     }
231 }