public void Store(ILocalizationInfo localizationInfo) { if (LocalizationInfos.Contains(CurrentThreadId)) LocalizationInfos[CurrentThreadId] = localizationInfo; else LocalizationInfos.Add(CurrentThreadId, localizationInfo); }
public LyricsFactory(int timeoutSeconds, string providers, ILocalizationInfo info) { lyricsApis = new List <ILyricsApi>(); lyricsApisPipe = new List <ILyricsApi>(); if (providers.ToLower().Contains("chartlyrics")) { lyricsApis.Add(new ChartLyricsApi(timeoutSeconds)); } if (providers.ToLower().Contains("lololyrics")) { lyricsApis.Add(new LololyricsApi(timeoutSeconds)); } if (providers.ToLower().Contains("metrolyrics")) { lyricsApis.Add(new MetroLyricsApi(timeoutSeconds)); } if (providers.ToLower().Contains("xiamilyrics")) { lyricsApis.Add(new XiamiLyricsApi(timeoutSeconds, info)); } if (providers.ToLower().Contains("neteaselyrics")) { lyricsApis.Add(new NeteaseLyricsApi(timeoutSeconds, info)); } }
public decimal Calculate(IEnumerable <Product> products, ILocalizationInfo localInfo) { decimal total = 0.0m; //add total of products foreach (var product in products) { total += product.Price; } decimal taxRate = 0.0m; switch (localInfo.Country) { case "us": taxRate = 0.05m; break; case "ca": taxRate = 0.15m; break; } total += (total * taxRate); return(total); }
public void Store(ILocalizationInfo localizationInfo) { if (HttpContext.Current.Items.Contains(LocalizationInfoKey)) HttpContext.Current.Items[LocalizationInfoKey] = localizationInfo; else HttpContext.Current.Items.Add(LocalizationInfoKey, localizationInfo); }
public LyricsControlViewModel(IUnityContainer container) : base(container) { this.container = container; this.info = container.Resolve <ILocalizationInfo>(); this.metadataService = container.Resolve <IMetadataService>(); this.playbackService = container.Resolve <IPlaybackService>(); this.eventAggregator = container.Resolve <IEventAggregator>(); this.highlightTimer.Interval = this.highlightTimerIntervalMilliseconds; this.highlightTimer.Elapsed += HighlightTimer_Elapsed; this.updateLyricsAfterEditingTimer.Interval = this.updateLyricsAfterEditingTimerIntervalMilliseconds; this.updateLyricsAfterEditingTimer.Elapsed += UpdateLyricsAfterEditingTimer_Elapsed; this.refreshTimer.Interval = this.refreshTimerIntervalMilliseconds; this.refreshTimer.Elapsed += RefreshTimer_Elapsed; this.playbackService.PlaybackPaused += (_, __) => this.highlightTimer.Stop(); this.playbackService.PlaybackResumed += (_, __) => this.highlightTimer.Start(); this.metadataService.MetadataChanged += (_) => this.RestartRefreshTimer(); SettingsClient.SettingChanged += (_, e) => { if (SettingsClient.IsSettingChanged(e, "Lyrics", "DownloadLyrics")) { if ((bool)e.SettingValue) { this.RestartRefreshTimer(); } } }; this.isNowPlayingPageActive = SettingsClient.Get <bool>("FullPlayer", "IsNowPlayingSelected"); this.isNowPlayingLyricsPageActive = ((NowPlayingSubPage)SettingsClient.Get <int>("FullPlayer", "SelectedNowPlayingSubPage")) == NowPlayingSubPage.Lyrics; this.eventAggregator.GetEvent <IsNowPlayingPageActiveChanged>().Subscribe(isNowPlayingPageActive => { this.isNowPlayingPageActive = isNowPlayingPageActive; this.RestartRefreshTimer(); }); this.eventAggregator.GetEvent <IsNowPlayingSubPageChanged>().Subscribe(tuple => { this.isNowPlayingLyricsPageActive = tuple.Item2 == NowPlayingSubPage.Lyrics; this.RestartRefreshTimer(); }); this.RefreshLyricsCommand = new DelegateCommand(() => this.RestartRefreshTimer(), () => !this.IsDownloadingLyrics); ApplicationCommands.RefreshLyricsCommand.RegisterCommand(this.RefreshLyricsCommand); this.playbackService.PlaybackSuccess += (_, e) => { this.ContentSlideInFrom = e.IsPlayingPreviousTrack ? -30 : 30; this.RestartRefreshTimer(); }; this.ClearLyrics(); // Makes sure the loading animation can be shown even at first start }
public double Calculate(IEnumerable <Product> products, ILocalizationInfo localInfo) { double total = products.Sum(p => p.Price); double taxRate = localInfo.getTaxRate(); total += (total * taxRate); return(total); }
public CurrencyRecord GetCurrency(ILocalizationInfo localizationInfo, string xcurrency) { var country = GetCountry(localizationInfo); var currency = (string.IsNullOrWhiteSpace(xcurrency)) ? country.CountryCurrencies.First().CurrencyRecord : GetAllCurrecies().Where(aa => aa.Code.ToLower() == xcurrency.Trim()).First(); return(currency); }
public void Fail(ILocalizationInfo localizationInfo) { var messageKey = !string.IsNullOrEmpty(this.Config[ApplicationConstants.CustomMessageKey] as string) ? this.Config["CustomMessageKey"] as string : this.ValidatorName; this.ValidationMessage = localizationInfo.GetValidationMessage(messageKey); if (string.IsNullOrEmpty(this.ValidationMessage)) { this.ValidationMessage = ApplicationConstants.Invalid; } }
public void Store(ILocalizationInfo localizationInfo) { if (HttpContext.Current.Items.Contains(LocalizationInfoKey)) { HttpContext.Current.Items[LocalizationInfoKey] = localizationInfo; } else { HttpContext.Current.Items.Add(LocalizationInfoKey, localizationInfo); } }
public ILocalizationInfo GetCurrentLocalizationInfo() { ILocalizationInfo localizationInfo = null; if (HttpContext.Current.Items.Contains(LocalizationInfoKey)) { localizationInfo = (ILocalizationInfo)HttpContext.Current.Items[LocalizationInfoKey]; } return(localizationInfo); }
public void Store(ILocalizationInfo localizationInfo) { if (LocalizationInfos.Contains(CurrentThreadId)) { LocalizationInfos[CurrentThreadId] = localizationInfo; } else { LocalizationInfos.Add(CurrentThreadId, localizationInfo); } }
public ILocalizationInfo GetCurrentLocalizationInfo() { ILocalizationInfo localizationInfo = null; if (LocalizationInfos.Contains(CurrentThreadId)) { localizationInfo = (ILocalizationInfo)LocalizationInfos[CurrentThreadId]; } return(localizationInfo); }
public decimal Calculate(IEnumerable <Product> products, ILocalizationInfo localInfo) { decimal total = 0.0m; //add total of products total = products.Sum(x => x.Price); total = (localInfo.Country == "us" ? total * 0.05m : total * 0.15m); return(total); }
public CountryRecord GetCountry(ILocalizationInfo localizationInfo) { var country = _countryRepository.Table .FirstOrDefault(c => c.Code == localizationInfo.CountryIsoCode); // ReSharper disable once ConvertIfStatementToNullCoalescingExpression if (country == null) { country = _countryRepository.Table.First(c => c.Code == UnitedStatesCountryIsoCode); } return country; }
public CountryRecord GetCountry(ILocalizationInfo localizationInfo) { var country = _countryRepository.Table .FirstOrDefault(c => c.Code == localizationInfo.CountryIsoCode); // ReSharper disable once ConvertIfStatementToNullCoalescingExpression if (country == null) { country = _countryRepository.Table.First(c => c.Code == UnitedStatesCountryIsoCode); } return(country); }
public FileService(ICacheService cacheService, ITrackStatisticRepository trackStatisticRepository, ILocalizationInfo info) { this.cacheService = cacheService; this.trackStatisticRepository = trackStatisticRepository; this.info = info; // Unique identifier which will be used by this instance only to create cached artwork. // This prevents the cleanup function to delete artwork which is in use by this instance. this.instanceGuid = Guid.NewGuid().ToString(); this.files = new List <string>(); this.addFilesTimer = new Timer(); this.addFilesTimer.Interval = this.addFilesMilliseconds; this.addFilesTimer.Elapsed += AddFilesTimerElapsedHandler; this.DeleteFileArtworkFromCacheAsync(this.instanceGuid); }
public LyricsControlViewModel(IUnityContainer container) : base(container) { this.container = container; this.info = container.Resolve <ILocalizationInfo>(); this.metadataService = container.Resolve <IMetadataService>(); this.playbackService = container.Resolve <IPlaybackService>(); this.eventAggregator = container.Resolve <IEventAggregator>(); this.highlightTimer.Interval = this.highlightTimerIntervalMilliseconds; this.highlightTimer.Elapsed += HighlightTimer_Elapsed; this.updateLyricsAfterEditingTimer.Interval = this.updateLyricsAfterEditingTimerIntervalMilliseconds; this.updateLyricsAfterEditingTimer.Elapsed += UpdateLyricsAfterEditingTimer_Elapsed; this.refreshTimer.Interval = this.refreshTimerIntervalMilliseconds; this.refreshTimer.Elapsed += RefreshTimer_Elapsed; this.playbackService.PlaybackPaused += (_, __) => this.highlightTimer.Stop(); this.playbackService.PlaybackResumed += (_, __) => this.highlightTimer.Start(); this.metadataService.MetadataChanged += (_) => this.RestartRefreshTimer(); SettingsClient.SettingChanged += (_, e) => { if (SettingsClient.IsSettingChanged(e, "Lyrics", "DownloadLyrics")) { if ((bool)e.SettingValue) { this.RestartRefreshTimer(); } } }; this.RefreshLyricsCommand = new DelegateCommand(() => this.RestartRefreshTimer(), () => !this.IsDownloadingLyrics); ApplicationCommands.RefreshLyricsCommand.RegisterCommand(this.RefreshLyricsCommand); this.playbackService.PlaybackSuccess += (isPlayingPreviousTrack) => { this.ContentSlideInFrom = isPlayingPreviousTrack ? -30 : 30; this.RestartRefreshTimer(); }; this.ClearLyrics(); // Makes sure the loading animation can be shown even at first start }
public NeteaseLyricsApi(int timeoutSeconds, ILocalizationInfo info) { this.timeoutSeconds = timeoutSeconds; this.info = info; httpClient = new HttpClient(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip }) { BaseAddress = new Uri(apiRootUrl) }; httpClient.DefaultRequestHeaders.Add("Accept-Encoding", "gzip,deflate,sdch"); httpClient.DefaultRequestHeaders.Add("Accept-Language", "en-US,zh-CN;q=0.8,zh;q=0.6,en;q=0.4"); httpClient.DefaultRequestHeaders.Add("Connection", "keep-alive"); httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"); httpClient.DefaultRequestHeaders.Add("Referer", "http://music.163.com/"); httpClient.DefaultRequestHeaders.Add("Host", "music.163.com"); httpClient.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); }
public LocalizationService(ILocalizationInfo localizationInfo, ISettings settings) { _localizationInfo = localizationInfo; _settings = settings; SupportedLanguages = new List <Language> { new Language { CultureInfo = new CultureInfo("en") }, new Language { CultureInfo = new CultureInfo("de") }, new Language { CultureInfo = new CultureInfo("it") }, new Language { CultureInfo = new CultureInfo("fr") }, }; InitializeCurrentLanguage(); }
public string Validate(object value, HttpContext httpContext, PropertyInfo property, ILocalizationInfo localizationInfo) { var propertyValue = property.GetValue(value); if (this.IsContinue(value)) { if (this.HaveValue(propertyValue)) { var connection = (IDatabaseFacade)httpContext.RequestServices.GetService(this.ConnectionType); if (connection != null) { var sqlConnection = new SqlConnection(connection.Database.GetDbConnection().ConnectionString); var type = value.GetType(); var tableAttribute = type.GetCustomAttributes(typeof(TableAttribute), true).SingleOrDefault() as TableAttribute; var primaryKeys = GetPrimaryKeys(type, value); if (tableAttribute != null) { var sqlCommand = DesignQuery(value, property, primaryKeys, tableAttribute); sqlCommand.Connection = sqlConnection; sqlConnection.Open(); var reader = sqlCommand.ExecuteReader(); if (reader.HasRows) { this.Fail(localizationInfo); } sqlConnection.Close(); reader.Close(); sqlConnection.Dispose(); } } } } if (this.ValidationMessage != null && value != null) { this.ValidationMessage = this.ValidationMessage.Replace("{0}", property.Name).Replace("{1}", value.ToString()); } return(this.ValidationMessage); }
public XiamiLyricsApi(int timeoutSeconds, ILocalizationInfo info) { this.timeoutSeconds = timeoutSeconds; this.info = info; }
public ArtistRepository(ISQLiteConnectionFactory factory, ILocalizationInfo info) { this.factory = factory; this.info = info; }
public string Validate(object entity, HttpContext httpContext, PropertyInfo property, ILocalizationInfo localizationInfo) { var propertyValue = property.GetValue(entity); if (this.IsContinue(entity)) { if (this.HaveValue(propertyValue)) { var value = propertyValue as string; var allowMaximumLength = (int)this.Config[ApplicationConstants.AllowMaximumLength]; if (!(value.Length <= allowMaximumLength)) { this.Fail(localizationInfo); } } } return(this.ValidationMessage); }
public string Validate(object entity, HttpContext httpContext, PropertyInfo property, ILocalizationInfo localizationInfo) { var propertyValue = property.GetValue(entity); if (this.IsContinue(entity)) { if (!((bool)this.Config[ApplicationConstants.AllowWhiteSpace])) { propertyValue = (propertyValue as string).Trim(); } if (!this.HaveValue(propertyValue)) { this.Fail(localizationInfo); } } return(this.ValidationMessage); }
public CartTotal(IEnumerable <Product> products, ILocalizationInfo localInfo) { this.products = products; this.localInfo = localInfo; }
public string Validate(object entity, HttpContext httpContext, PropertyInfo property, ILocalizationInfo localizationInfo) { var propertyValue = property.GetValue(entity); if (this.IsContinue(entity)) { if (this.HaveValue(propertyValue)) { if (property.PropertyType == typeof(int)) { var allowMinimum = (int)this.Config[ApplicationConstants.AllowMinimum]; var allowMaximum = (int)this.Config[ApplicationConstants.AllowMaximum]; var value = (int)propertyValue; if (!(value >= allowMinimum && value <= allowMaximum)) { this.Fail(localizationInfo); } } } } return(this.ValidationMessage); }
public CurrencyRecord GetCurrency(ILocalizationInfo localizationInfo) { var country = GetCountry(localizationInfo); var currency = country.CountryCurrencies.First().CurrencyRecord; return currency; }
public decimal Calculate(IEnumerable <Product> products, ILocalizationInfo localInfo) { return(products.Sum(x => x.Price) * (1 + _rateLookup[localInfo.Country])); }