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 /// Destroy the SearchPreference object.
57 /// Gets or sets a preferred language.
59 /// <since_tizen> 3 </since_tizen>
60 /// <remarks>Language should be specified as an ISO 3166 alpha-2 two letter country-code
61 /// followed by ISO 639-1 for the two-letter language code.<br/>e.g. "ko-KR", "en-US".</remarks>
62 public string Language
66 return handle.Language;
70 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
71 handle.Language = value;
76 /// Gets or sets the maximum result count for each service request.
78 /// <since_tizen> 3 </since_tizen>
79 /// <remarks>Setting negative value will not have any effect on MaxResults value.</remarks>
84 return handle.MaxResult;
88 Log.Info(string.Format("MaxResult is changed from {0} to {1}", handle.MaxResult, value));
89 handle.MaxResult = value;
94 /// Gets or sets the distance unit.
96 /// <since_tizen> 3 </since_tizen>
97 public DistanceUnit Unit
101 return (DistanceUnit)handle.Unit;
105 Log.Info(string.Format("Unit is changed from {0} to {1}", handle.Unit, value));
106 handle.Unit = (Interop.DistanceUnit)value;
111 /// Gets or sets the preferred country.
113 /// <since_tizen> 3 </since_tizen>
114 public string CountryCode
118 return handle.CountryCode;
122 Log.Info(string.Format("CountryCode is changed from {0} to {1}", handle.CountryCode, value));
123 handle.CountryCode = value;
128 /// Gets or sets the search properties as a key value pair.
130 /// <since_tizen> 3 </since_tizen>
131 public IReadOnlyDictionary<string, string> Properties
135 Action<string, string> action = (key, value) =>
137 _properties[key] = value;
140 handle.ForeachProperty(action);
141 return (IReadOnlyDictionary<string, string>)_properties;
145 foreach (var prop in value)
147 _properties[prop.Key] = prop.Value;
148 handle.SetProperty(prop.Key, prop.Value);
149 Log.Info(string.Format("Properties is changed to [{0}, {1}]", prop.Key, prop.Value));
155 /// Gets or sets the route optimization.
157 /// <since_tizen> 3 </since_tizen>
158 public RouteOptimization Optimization
162 return (RouteOptimization)handle.Optimization;
166 Log.Info(string.Format("Optimization is changed from {0} to {1}", handle.Optimization, value));
167 handle.Optimization = (Interop.RouteOptimization)value;
172 /// Gets or sets the route transport mode.
174 /// <since_tizen> 3 </since_tizen>
175 public TransportMode Mode
179 return (TransportMode)handle.TransportMode;
183 Log.Info(string.Format("TransportMode is changed from {0} to {1}", handle.TransportMode, value));
184 handle.TransportMode = (Interop.RouteTransportMode)value;
189 /// Gets or sets the route feature weight.
191 /// <since_tizen> 3 </since_tizen>
192 public RouteFeatureWeight RouteFeatureWeight
196 return (RouteFeatureWeight)handle.FeatureWeight;
200 Log.Info(string.Format("RouteFeatureWeight is changed from {0} to {1}", handle.FeatureWeight, value));
201 handle.FeatureWeight = (Interop.RouteFeatureWeight)value;
206 /// Gets or sets the route feature.
208 /// <since_tizen> 3 </since_tizen>
209 public RouteFeature RouteFeature
213 return (RouteFeature)handle.Feature;
217 Log.Info(string.Format("RouteFeature is changed from {0} to {1}", handle.Feature, value));
218 handle.Feature = (Interop.RouteRequestFeature)value;
223 /// Gets or sets if the searching for alternative routes is enabled.
225 /// <since_tizen> 3 </since_tizen>
226 public bool SearchAlternativeRoutes
230 return handle.AlternativesEnabled;
234 Log.Info(string.Format("SearchAlternativeRoutes is {0}", (value ? "enabled" : "disabled")));
235 handle.AlternativesEnabled = value;
239 #region IDisposable Support
240 private bool _disposedValue = false;
243 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
245 /// <param name="disposing">If true, managed and unmanaged resources can be disposed, otherwise only unmanaged resources can be disposed.</param>
246 /// <since_tizen> 3 </since_tizen>
247 protected virtual void Dispose(bool disposing)
252 _disposedValue = true;
257 /// Releases all the resources used by this object.
259 /// <since_tizen> 3 </since_tizen>
260 public void Dispose()
263 GC.SuppressFinalize(this);