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