2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
23 /// Preferences for route search requests.
25 /// <since_tizen> 3 </since_tizen>
26 public class SearchPreference : IGeocodePreference, IPlaceSearchPreference, IRouteSearchPreference, IDisposable
28 internal Interop.PreferenceHandle handle;
29 private IDictionary<string, string> _properties = new Dictionary<string, string>();
32 /// Constructor for a new search preference.
34 /// <since_tizen> 3 </since_tizen>
35 public SearchPreference()
37 handle = new Interop.PreferenceHandle();
41 /// Constructor for a new search preference.
43 internal SearchPreference(Interop.PreferenceHandle nativeHandle)
45 handle = nativeHandle;
49 /// Gets or sets a preferred language.
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
58 return handle.Language;
62 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
63 handle.Language = value;
68 /// Gets or sets the maximum result count for each service request.
70 /// <since_tizen> 3 </since_tizen>
71 /// <remarks>Setting negative value will not have any effect on MaxResults value.</remarks>
76 return handle.MaxResult;
80 Log.Info(string.Format("MaxResult is changed from {0} to {1}", handle.MaxResult, value));
81 handle.MaxResult = value;
86 /// Gets or sets the distance unit.
88 /// <since_tizen> 3 </since_tizen>
89 public DistanceUnit Unit
93 return (DistanceUnit)handle.Unit;
97 Log.Info(string.Format("Unit is changed from {0} to {1}", handle.Unit, value));
98 handle.Unit = (Interop.DistanceUnit)value;
103 /// Gets or sets the preferred country.
105 /// <since_tizen> 3 </since_tizen>
106 public string CountryCode
110 return handle.CountryCode;
114 Log.Info(string.Format("CountryCode is changed from {0} to {1}", handle.CountryCode, value));
115 handle.CountryCode = value;
120 /// Gets or sets the search properties as a key value pair.
122 /// <since_tizen> 3 </since_tizen>
123 public IReadOnlyDictionary<string, string> Properties
127 Action<string, string> action = (key, value) =>
129 _properties[key] = value;
132 handle.ForeachProperty(action);
133 return (IReadOnlyDictionary<string, string>)_properties;
137 foreach (var prop in value)
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));
147 /// Gets or sets the route optimization.
149 /// <since_tizen> 3 </since_tizen>
150 public RouteOptimization Optimization
154 return (RouteOptimization)handle.Optimization;
158 Log.Info(string.Format("Optimization is changed from {0} to {1}", handle.Optimization, value));
159 handle.Optimization = (Interop.RouteOptimization)value;
164 /// Gets or sets the route transport mode.
166 /// <since_tizen> 3 </since_tizen>
167 public TransportMode Mode
171 return (TransportMode)handle.TransportMode;
175 Log.Info(string.Format("TransportMode is changed from {0} to {1}", handle.TransportMode, value));
176 handle.TransportMode = (Interop.RouteTransportMode)value;
181 /// Gets or sets the route feature weight.
183 /// <since_tizen> 3 </since_tizen>
184 public RouteFeatureWeight RouteFeatureWeight
188 return (RouteFeatureWeight)handle.FeatureWeight;
192 Log.Info(string.Format("RouteFeatureWeight is changed from {0} to {1}", handle.FeatureWeight, value));
193 handle.FeatureWeight = (Interop.RouteFeatureWeight)value;
198 /// Gets or sets the route feature.
200 /// <since_tizen> 3 </since_tizen>
201 public RouteFeature RouteFeature
205 return (RouteFeature)handle.Feature;
209 Log.Info(string.Format("RouteFeature is changed from {0} to {1}", handle.Feature, value));
210 handle.Feature = (Interop.RouteRequestFeature)value;
215 /// Gets or sets if the searching for alternative routes is enabled.
217 /// <since_tizen> 3 </since_tizen>
218 public bool SearchAlternativeRoutes
222 return handle.AlternativesEnabled;
226 Log.Info(string.Format("SearchAlternativeRoutes is {0}", (value ? "enabled" : "disabled")));
227 handle.AlternativesEnabled = value;
231 #region IDisposable Support
232 private bool _disposedValue = false;
234 protected virtual void Dispose(bool disposing)
239 _disposedValue = true;
244 /// Releases all the resources used by this object.
246 /// <since_tizen> 3 </since_tizen>
247 public void Dispose()
250 GC.SuppressFinalize(this);