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 public class SearchPreference : IGeocodePreference, IPlaceSearchPreference, IRouteSearchPreference, IDisposable
27 internal Interop.PreferenceHandle handle;
28 private IReadOnlyDictionary<string, string> _properties = new Dictionary<string, string>();
31 /// Constructors a new search preference.
33 public SearchPreference()
35 handle = new Interop.PreferenceHandle();
39 /// Constructors a new search preference.
41 internal SearchPreference(Interop.PreferenceHandle nativeHandle)
43 handle = nativeHandle;
47 /// Gets or sets preferred language.
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
55 return handle.Language;
59 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
60 handle.Language = value;
65 /// Gets or sets the maximum result count for each service request.
67 /// <remarks>Setting negative value will not have any effect on MaxResults value</remarks>
72 return handle.MaxResult;
76 Log.Info(string.Format("MaxResult is changed from {0} to {1}", handle.MaxResult, value));
77 handle.MaxResult = value;
82 /// Gets or sets distance unit.
84 public DistanceUnit Unit
88 return (DistanceUnit)handle.Unit;
92 Log.Info(string.Format("Unit is changed from {0} to {1}", handle.Unit, value));
93 handle.Unit = (Interop.DistanceUnit)value;
98 /// Gets or sets preferred country.
100 public string CountryCode
104 return handle.CountryCode;
108 Log.Info(string.Format("CountryCode is changed from {0} to {1}", handle.CountryCode, value));
109 handle.CountryCode = value;
114 /// Gets or sets search properties as key value pair.
116 public IReadOnlyDictionary<string, string> Properties
124 Log.Info(string.Format("Properties is changed from {0} to {1}", Properties.ToString(), value.ToString()));
130 /// Gets or sets route optimization.
132 public RouteOptimization Optimization
136 return (RouteOptimization)handle.Optimization;
140 Log.Info(string.Format("Optimization is changed from {0} to {1}", handle.Optimization, value));
141 handle.Optimization = (Interop.RouteOptimization)value;
146 /// Gets or sets route transport mode.
148 public TransportMode Mode
152 return (TransportMode)handle.TransportMode;
156 Log.Info(string.Format("TransportMode is changed from {0} to {1}", handle.TransportMode, value));
157 handle.TransportMode = (Interop.RouteTransportMode)value;
162 /// Gets or sets route feature weight.
164 public RouteFeatureWeight RouteFeatureWeight
168 return (RouteFeatureWeight)handle.FeatureWeight;
172 Log.Info(string.Format("RouteFeatureWeight is changed from {0} to {1}", handle.FeatureWeight, value));
173 handle.FeatureWeight = (Interop.RouteFeatureWeight)value;
178 /// Gets or sets route feature.
180 public RouteFeature RouteFeature
184 return (RouteFeature)handle.Feature;
188 Log.Info(string.Format("RouteFeature is changed from {0} to {1}", handle.Feature, value));
189 handle.Feature = (Interop.RouteRequestFeature)value;
194 /// Gets or sets if searching for alternative routes is enabled.
196 public bool SearchAlternativeRoutes
200 return handle.AlternativesEnabled;
204 Log.Info(string.Format("SearchAlternativeRoutes is {0}", (value ? "enabled" : "disabled")));
205 handle.AlternativesEnabled = value;
209 #region IDisposable Support
210 private bool _disposedValue = false;
212 protected virtual void Dispose(bool disposing)
217 _disposedValue = true;
222 /// Releases all resources used by this object.
224 public void Dispose()
227 GC.SuppressFinalize(this);