/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; namespace Tizen.Maps { /// /// Preferences for route search requests /// /// 3 public class SearchPreference : IGeocodePreference, IPlaceSearchPreference, IRouteSearchPreference, IDisposable { internal Interop.PreferenceHandle handle; private IDictionary _properties = new Dictionary(); /// /// Constructors a new search preference. /// /// 3 public SearchPreference() { handle = new Interop.PreferenceHandle(); } /// /// Constructors a new search preference. /// internal SearchPreference(Interop.PreferenceHandle nativeHandle) { handle = nativeHandle; } /// /// Gets or sets preferred language. /// /// 3 /// 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", "en-US".
public string Language { get { return handle.Language; } set { Log.Info(string.Format("Language is changed from {0} to {1}", handle.Language, value)); handle.Language = value; } } /// /// Gets or sets the maximum result count for each service request. /// /// 3 /// Setting negative value will not have any effect on MaxResults value public int MaxResults { get { return handle.MaxResult; } set { Log.Info(string.Format("MaxResult is changed from {0} to {1}", handle.MaxResult, value)); handle.MaxResult = value; } } /// /// Gets or sets distance unit. /// /// 3 public DistanceUnit Unit { get { return (DistanceUnit)handle.Unit; } set { Log.Info(string.Format("Unit is changed from {0} to {1}", handle.Unit, value)); handle.Unit = (Interop.DistanceUnit)value; } } /// /// Gets or sets preferred country. /// /// 3 public string CountryCode { get { return handle.CountryCode; } set { Log.Info(string.Format("CountryCode is changed from {0} to {1}", handle.CountryCode, value)); handle.CountryCode = value; } } /// /// Gets or sets search properties as key value pair. /// /// 3 public IReadOnlyDictionary Properties { get { Action action = (key, value) => { _properties[key] = value; }; handle.ForeachProperty(action); return (IReadOnlyDictionary)_properties; } set { foreach (var prop in value) { _properties[prop.Key] = prop.Value; handle.SetProperty(prop.Key, prop.Value); Log.Info(string.Format("Properties is changed to [{0}, {1}]", prop.Key, prop.Value)); } } } /// /// Gets or sets route optimization. /// /// 3 public RouteOptimization Optimization { get { return (RouteOptimization)handle.Optimization; } set { Log.Info(string.Format("Optimization is changed from {0} to {1}", handle.Optimization, value)); handle.Optimization = (Interop.RouteOptimization)value; } } /// /// Gets or sets route transport mode. /// /// 3 public TransportMode Mode { get { return (TransportMode)handle.TransportMode; } set { Log.Info(string.Format("TransportMode is changed from {0} to {1}", handle.TransportMode, value)); handle.TransportMode = (Interop.RouteTransportMode)value; } } /// /// Gets or sets route feature weight. /// /// 3 public RouteFeatureWeight RouteFeatureWeight { get { return (RouteFeatureWeight)handle.FeatureWeight; } set { Log.Info(string.Format("RouteFeatureWeight is changed from {0} to {1}", handle.FeatureWeight, value)); handle.FeatureWeight = (Interop.RouteFeatureWeight)value; } } /// /// Gets or sets route feature. /// /// 3 public RouteFeature RouteFeature { get { return (RouteFeature)handle.Feature; } set { Log.Info(string.Format("RouteFeature is changed from {0} to {1}", handle.Feature, value)); handle.Feature = (Interop.RouteRequestFeature)value; } } /// /// Gets or sets if searching for alternative routes is enabled. /// /// 3 public bool SearchAlternativeRoutes { get { return handle.AlternativesEnabled; } set { Log.Info(string.Format("SearchAlternativeRoutes is {0}", (value ? "enabled" : "disabled"))); handle.AlternativesEnabled = value; } } #region IDisposable Support private bool _disposedValue = false; protected virtual void Dispose(bool disposing) { if (!_disposedValue) { handle.Dispose(); _disposedValue = true; } } /// /// Releases all resources used by this object. /// /// 3 public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion } }