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 /// Constructor for search preference
33 public SearchPreference()
35 handle = new Interop.PreferenceHandle();
39 /// Constructor for search preference
41 internal SearchPreference(Interop.PreferenceHandle nativeHandle)
43 handle = nativeHandle;
47 /// Preferred language
50 /// Language should be specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code e.g. "ko-KR"
52 public string Language
56 return handle.Language;
60 Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value));
61 handle.Language = value;
66 /// Maximum result count for a service request
68 /// <remarks>Setting negative value will not have any effect on MaxResults value</remarks>
73 return handle.MaxResult;
77 Log.Info(string.Format("MaxResult is changed from {0} to {1}", handle.MaxResult, value));
78 handle.MaxResult = value;
85 public DistanceUnit Unit
89 return (DistanceUnit)handle.Unit;
93 Log.Info(string.Format("Unit is changed from {0} to {1}", handle.Unit, value));
94 handle.Unit = (Interop.DistanceUnit)value;
101 public string CountryCode
105 return handle.CountryCode;
109 Log.Info(string.Format("CountryCode is changed from {0} to {1}", handle.CountryCode, value));
110 handle.CountryCode = value;
115 /// Search properties as key value pair
117 public IReadOnlyDictionary<string, string> Properties
125 Log.Info(string.Format("Properties is changed from {0} to {1}", Properties.ToString(), value.ToString()));
131 /// Selected route optimization
133 public RouteOptimization Optimization
137 return (RouteOptimization)handle.Optimization;
141 Log.Info(string.Format("Optimization is changed from {0} to {1}", handle.Optimization, value));
142 handle.Optimization = (Interop.RouteOptimization)value;
147 /// Route transport mode
149 public TransportMode Mode
153 return (TransportMode)handle.TransportMode;
157 Log.Info(string.Format("TransportMode is changed from {0} to {1}", handle.TransportMode, value));
158 handle.TransportMode = (Interop.RouteTransportMode)value;
163 /// Route feature weight
165 public RouteFeatureWeight RouteFeatureWeight
169 return (RouteFeatureWeight)handle.FeatureWeight;
173 Log.Info(string.Format("RouteFeatureWeight is changed from {0} to {1}", handle.FeatureWeight, value));
174 handle.FeatureWeight = (Interop.RouteFeatureWeight)value;
181 public RouteFeature RouteFeature
185 return (RouteFeature)handle.Feature;
189 Log.Info(string.Format("RouteFeature is changed from {0} to {1}", handle.Feature, value));
190 handle.Feature = (Interop.RouteRequestFeature)value;
195 /// Indicate if search for alternative routes is enabled.
197 public bool SearchAlternativeRoutes
201 return handle.AlternativesEnabled;
205 Log.Info(string.Format("SearchAlternativeRoutes is {0}", (value ? "enabled" : "disabled")));
206 handle.AlternativesEnabled = value;
210 #region IDisposable Support
211 private bool _disposedValue = false;
213 protected virtual void Dispose(bool disposing)
218 _disposedValue = true;
222 public void Dispose()
225 GC.SuppressFinalize(this);