public ProfileController(ILogger <HomeController> logger, LocalizationService localizationService, StatusService statusService, ProfileRepository profileRepository, ContentRepository contentRepository, AccountRepository accountRepository, FileStorageService fileStorageService, IHostingEnvironment environment, LocalizationRepository localizationRepository, ViewFieldsRepository viewFieldsRepository, ProfileService profileService, EmailService emailService, CityRepository cityRepository ) { _logger = logger; _localizationService = localizationService; _statusService = statusService; _profileRepository = profileRepository; _contentRepository = contentRepository; _accountRepository = accountRepository; _fileStorageService = fileStorageService; _localizationRepository = localizationRepository; _environment = environment; _viewFieldsRepository = viewFieldsRepository; _profileService = profileService; _emailService = emailService; _cityRepository = cityRepository; }
public void CheckConstructorWithParameters_CheckNullableTokenRepository_ShouldThrowException() { // Arrange var localizationRepository = new LocalizationRepository(); // Assert Assert.Throws <ArgumentNullException>(() => new LocalApi(null, localizationRepository)); }
public void ChangeLanguage(string languageCode) { if (LanguageRepository.Exists(l => l.Code == languageCode)) { LocalizationRepository = new JsonLocalizationRepository(languageCode, LocalizableCodeRepository); LanguageChanged?.Invoke(this, languageCode); } }
protected override void OnSendNotification(string title, string message, string testing) { Logger.Write("UI: Request Showing Taost received...", LogLevel.Debug); if (MainControl.DisableToasts.Checked) { Logger.Write("UI: Toasts are disabled!", LogLevel.Debug); return; } if (MainControl.EnableActToast.Checked) { Logger.Write("UI: Using ACT Toasts", LogLevel.Debug); var traySlider = new TraySlider(); traySlider.ShowDurationMs = 30000; traySlider.ButtonSE.Visible = false; traySlider.ButtonNE.Visible = false; traySlider.ButtonNW.Visible = false; traySlider.ButtonSW.Visible = true; traySlider.ButtonSW.Text = LocalizationRepository.GetText("ui-close-act-toast"); traySlider.TrayTitle.Font = new Font(FontFamily.GenericSerif, 16, FontStyle.Bold); traySlider.TrayText.Font = new Font(FontFamily.GenericSerif, 12, FontStyle.Regular); if (!string.IsNullOrWhiteSpace(testing)) { message += $"\nCode [{testing}]"; } traySlider.ShowTraySlider(message, title); } else { Logger.Write("UI: Using Windows Toasts", LogLevel.Debug); try { // clearing old toasts if needed DesktopNotificationManagerCompat.History.Clear(); Logger.Write("UI: Creating new Toast...", LogLevel.Debug); ToastManager.ShowToast(title, message, testing); } catch (Exception e) { Logger.Write(e, "UI: Using built in notifier...", LogLevel.Error); var icon = new NotifyIcon { Icon = SystemIcons.WinLogo, Text = "DFAssist", Visible = true, BalloonTipTitle = title, BalloonTipText = message }; icon.ShowBalloonTip(3000); icon.Dispose(); } } }
/// <summary> /// Combine all possible sources of localized string for a given (culture) /// into a single Tree containing the most relevent localizations. /// /// This The localization a found in Resx files /// The Possible sources are resx files configured in most relevent file first /// <example> /// ComposerConfiguration.ResxLocalizationRepositoryConfiguration.PatternsForPossibleSources = { /// "{category}_Custom.{cultureName}.resx", /// "{category}_Custom.{twoLetterISOLanguageName}.resx", /// "{category}_Custom.resx", /// "{category}.{cultureName}.resx", /// "{category}.{twoLetterISOLanguageName}.resx", /// "{category}.resx", /// }; /// </example> /// /// <example> /// string value = await tree.LocalizedCategories[category].LocalizedValues[key].ConfigureAwait(false); /// </example> /// </summary> /// <param name="culture"></param> /// <returns>Tree of most relevant localized values</returns> public Task <LocalizationTree> GetLocalizationTreeAsync(CultureInfo culture) { if (culture == null) { throw new ArgumentNullException("culture"); } CacheKey localizationTreeCacheKey = new CacheKey(CacheConfigurationCategoryNames.LocalizationTree) { CultureInfo = culture, }; var value = CacheProvider.GetOrAddAsync(localizationTreeCacheKey, async() => { string folderPhysicalPath = ""; LocalizationTree tree = new LocalizationTree(culture); foreach (var categoryName in LocalizationRepository.GetAllCategories()) { LocalizationCategory category = new LocalizationCategory(categoryName); foreach (var source in LocalizationRepository.GetPrioritizedSources(categoryName, culture)) { Dictionary <string, string> values = await LocalizationRepository.GetValuesAsync(source).ConfigureAwait(false); foreach (var kvp in values) { if (!category.LocalizedValues.ContainsKey(kvp.Key)) { category.LocalizedValues.Add(kvp.Key, kvp.Value); } } Regex meinReg = new Regex("^[a-zA-Z]{1}:\\.*"); if (string.IsNullOrEmpty(folderPhysicalPath) && !meinReg.IsMatch(source.VirtualPath)) { folderPhysicalPath = HostingEnvironment.MapPath(source.VirtualPath.Substring(0, source.VirtualPath.LastIndexOf(source.Name))); } } tree.LocalizedCategories.Add(categoryName.ToLowerInvariant(), category); } MonitorLocalizationFiles(localizationTreeCacheKey, folderPhysicalPath); return(tree); }); return(value); }
public LocalizationRepositoryTests() { localization = new Localization { Culture = "ru-RU" }; var culture = "{\"Culture\":\"ru-RU\"}"; settingsRepositoryMock = new Mock <ISettingsRepository>(); settingsRepositoryMock .Setup(sr => sr.GetByNameAsync(It.IsAny <string>())) .ReturnsAsync(culture); settingsRepositoryMock.Setup(sr => sr.SaveAsync(It.IsAny <string>(), It.IsAny <string>())); localizationRepository = new LocalizationRepository(settingsRepositoryMock.Object); }
public override void ConvertToPersistent(Localization disconnectedEntity, Localization persistent = null, Func <Localization> populatePersistent = null) { populatePersistent = () => { using (var uow = new Dota2UnitofWork()) { var repository = new LocalizationRepository(uow.Context); return(repository.Select(repository.UniqueFilter(disconnectedEntity), repository.GetAllIncludes()) .Select(q => new { q.Id, q.BaseObjectId, q.LanguageId, q.PropertyName }) .ToList() .Select(l => new Localization() { Id = l.Id, BaseObjectId = l.BaseObjectId, LanguageId = l.LanguageId, PropertyName = l.PropertyName }) .SingleOrDefault()); } }; persistent = persistent ?? populatePersistent(); if (persistent == null) { return; } persistent.Language = new LanguageService(false).Get(l => l.Id == persistent.LanguageId); if (disconnectedEntity.Language != null && persistent.Language != null) { new LanguageService().ConvertToPersistent(disconnectedEntity.Language, persistent.Language); disconnectedEntity.LanguageId = disconnectedEntity.Language.Id; } base.ConvertToPersistent(disconnectedEntity, persistent, populatePersistent); }
[UsedImplicitly] // by ninject public Loader( CardRepository repository, ImageRepository imageRepository, LocalizationRepository localizationRepository, CardSearcher cardSearcher, KeywordSearcher keywordSearcher, PriceRepository priceRepository, IApplication application) { _repository = repository; _imageRepository = imageRepository; _localizationRepository = localizationRepository; _cardSearcher = cardSearcher; _keywordSearcher = keywordSearcher; _priceRepository = priceRepository; _application = application; createLoadingActions(); }
public void Setup() { _repo = new CardRepository { FilterSetCode = F.IsEqualTo("ISD", Str.Comparer) }; _localizationRepo = new LocalizationRepository(); _cardSearcher = new CardSearcher(_repo, new CardDocumentAdapter(_repo)); _keywordSearcher = new KeywordSearcher(_repo); _repo.LoadFile(); _repo.Load(); _localizationRepo.LoadFile(); _localizationRepo.Load(); _repo.FillLocalizations(_localizationRepo); }
protected override void OnSendNotification(string title, string message, string testing) { Logger.Write("UI: Request Showing Taost received...", LogLevel.Debug); if (MainControl.DisableToasts.Checked) { Logger.Write("UI: Toasts are disabled!", LogLevel.Debug); return; } if (MainControl.EnableActToast.Checked) { Logger.Write("UI: Using ACT Toasts", LogLevel.Debug); var traySlider = new TraySlider { Font = new Font(FontFamily.GenericSerif, 16, FontStyle.Bold), ShowDurationMs = 30000 }; traySlider.ButtonSE.Visible = false; traySlider.ButtonNE.Visible = false; traySlider.ButtonNW.Visible = false; traySlider.ButtonSW.Visible = true; traySlider.ButtonSW.Text = LocalizationRepository.GetText("ui-close-act-toast"); traySlider.ShowTraySlider($"{message}\n{testing}", title); } else { Logger.Write("UI: Using Windows Toasts", LogLevel.Debug); try { Logger.Write("UI: Creating new Toast...", LogLevel.Debug); var attribution = nameof(DFAssist); if (string.IsNullOrWhiteSpace(testing)) { WinToastWrapper.CreateToast( DFAssistPlugin.AppId, DFAssistPlugin.AppId, title, message, _toastEventCallback, attribution, true, Duration.Long); } else { WinToastWrapper.CreateToast( DFAssistPlugin.AppId, DFAssistPlugin.AppId, title, message, $"Code [{testing}]", _toastEventCallback, attribution, Duration.Long); } } catch (Exception e) { Logger.Write(e, "UI: Unable to show toast notification", LogLevel.Error); } } }
public NeverDebuggingContext(LocalizationRepository repository) { Repository = repository; }
public AlwaysDebuggingContext(LocalizationRepository repository) { Repository = repository; }
/// <summary> /// Provides Localization Helper. /// </summary> /// <param name="helper">Current HTML Helper</param> /// <param name="repository">Repository to draw localizations from</param> /// <param name="debug">Whether or not to allow debug mode</param> /// <returns></returns> public static LocalizationHelper Local(this HtmlHelper helper, LocalizationRepository repository, bool debug) { return(new LocalizationHelper(helper, debug, new RepositoryWrapper(repository, repository.DefaultPart))); }
public RepositoryWrapper(LocalizationRepository repo, Part partOverride) { InnerRepository = repo; PartOverride = partOverride; }
public LocalizationSystem() { LanguageRepository = new JsonLanguageRepository(); LocalizableCodeRepository = new JsonLocalizableCodeRepository(); LocalizationRepository = new JsonLocalizationRepository("en_EN", LocalizableCodeRepository); }
public RepositoryWrapper(LocalizationRepository repo, Part partOverride, String abSegment = null) { InnerRepository = repo; PartOverride = partOverride; ABSegment = abSegment; }
public LocalizationController(LocalizationRepository localizationRepository) { _localizationRepository = localizationRepository; }
public ManualConfigurationContext(LocalizationRepository repository, bool debugMode) { Repository = repository; DebugMode = debugMode; }