/// <summary> /// Returns a new model. /// </summary> /// <param name="isLocalAddress"></param> /// <returns></returns> public static ServerConfigJson ToModel(bool isLocalAddress) { var applicationInformation = Factory.Resolve <IApplicationInformation>(); var runtimeEnvironment = Factory.ResolveSingleton <IRuntimeEnvironment>(); var configuration = Factory.ResolveSingleton <ISharedConfiguration>().Get(); var tileServerSettingsManager = Factory.ResolveSingleton <ITileServerSettingsManager>(); var tileServerSettings = tileServerSettingsManager.GetTileServerSettings( configuration.GoogleMapSettings.MapProvider, configuration.GoogleMapSettings.TileServerSettingName, fallbackToDefaultIfMissing: true ); var isMono = runtimeEnvironment.IsMono; var result = new ServerConfigJson() { InitialDistanceUnit = GetDistanceUnit(configuration.GoogleMapSettings.InitialDistanceUnit), InitialHeightUnit = GetHeightUnit(configuration.GoogleMapSettings.InitialHeightUnit), InitialLatitude = configuration.GoogleMapSettings.InitialMapLatitude, InitialLongitude = configuration.GoogleMapSettings.InitialMapLongitude, InitialMapType = GetMapType(configuration.GoogleMapSettings.InitialMapType), InitialSettings = configuration.GoogleMapSettings.InitialSettings, InitialSpeedUnit = GetSpeedUnit(configuration.GoogleMapSettings.InitialSpeedUnit), InitialZoom = configuration.GoogleMapSettings.InitialMapZoom, InternetClientCanRunReports = configuration.InternetClientSettings.CanRunReports, InternetClientCanShowPinText = configuration.InternetClientSettings.CanShowPinText, InternetClientsCanPlayAudio = configuration.InternetClientSettings.CanPlayAudio, InternetClientsCanSubmitRoutes = configuration.InternetClientSettings.CanSubmitRoutes, InternetClientsCanSeeAircraftPictures = configuration.InternetClientSettings.CanShowPictures, InternetClientsCanSeePolarPlots = configuration.InternetClientSettings.CanShowPolarPlots, InternetClientTimeoutMinutes = configuration.InternetClientSettings.TimeoutMinutes, IsAudioEnabled = configuration.AudioSettings.Enabled, IsLocalAddress = isLocalAddress, IsMono = isMono, UseMarkerLabels = isMono ? configuration.MonoSettings.UseMarkerLabels : false, UseSvgGraphicsOnDesktop = configuration.GoogleMapSettings.UseSvgGraphicsOnDesktop, UseSvgGraphicsOnMobile = configuration.GoogleMapSettings.UseSvgGraphicsOnMobile, UseSvgGraphicsOnReports = configuration.GoogleMapSettings.UseSvgGraphicsOnReports, MinimumRefreshSeconds = configuration.GoogleMapSettings.MinimumRefreshSeconds, RefreshSeconds = configuration.GoogleMapSettings.InitialRefreshSeconds, TileServerSettings = tileServerSettings, VrsVersion = applicationInformation.IsBeta ? $"{applicationInformation.ShortVersion} {Strings.Beta}" : applicationInformation.ShortVersion, }; result.Receivers.AddRange(configuration.Receivers.Select(r => ServerReceiverJson.ToModel(r)).Where(r => r != null)); result.Receivers.AddRange(configuration.MergedFeeds.Select(r => ServerReceiverJson.ToModel(r)).Where(r => r != null)); if (!isLocalAddress || configuration.GoogleMapSettings.UseGoogleMapsAPIKeyWithLocalRequests) { result.GoogleMapsApiKey = configuration.GoogleMapSettings.GoogleMapsApiKey; if (result.GoogleMapsApiKey == "") { result.GoogleMapsApiKey = null; } } return(result); }
/// <summary> /// Returns a new object from a merged feed. /// </summary> /// <param name="mergedFeed"></param> /// <returns></returns> public static ServerReceiverJson ToModel(MergedFeed mergedFeed) { ServerReceiverJson result = null; if (mergedFeed != null && mergedFeed.ReceiverUsage == ReceiverUsage.Normal) { result = new ServerReceiverJson() { UniqueId = mergedFeed.UniqueId, Name = mergedFeed.Name, }; } return(result); }
/// <summary> /// Returns a new object from a receiver. /// </summary> /// <param name="receiver"></param> /// <returns></returns> public static ServerReceiverJson ToModel(Receiver receiver) { ServerReceiverJson result = null; if (receiver != null && receiver.ReceiverUsage == ReceiverUsage.Normal) { result = new ServerReceiverJson() { UniqueId = receiver.UniqueId, Name = receiver.Name, }; } return(result); }