public NewUnitTypeValidator( ITranslationsService translationsService, ICompanyService companyService) : base(companyService, translationsService) { RuleFor(x => x.Name).NotNull().NotEmpty().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.Name).Length(1, 100).WithMessage(string.Format(translationsService.GetTranslationByKey("validations.lessThan"), 100)); }
public UnitTestBase() { var testContainer = new TestsContainer(); _container = testContainer.GetContainerBuilder(); _container.Resolve <IEnumerable <IMapConfiguration> >().ToList().ForEach(x => x.Map()); _container.Resolve <IEventRegisterListeners>().RegisterListeners(); _translationsService = _container.Resolve <ITranslationsService>(); _emailSenderMock = testContainer.EmailSenderMoq; HttpContext.Current = HttpContext.Current = new HttpContext( new HttpRequest("", "http://tempuri.org", ""), new HttpResponse(new StringWriter()) ); HttpContext.Current.User = new GenericPrincipal( new ClaimsIdentity(new[] { new Claim(ClaimTypes.Role, RoleIds.SuperAdmin.ToString()), new Claim(ClaimTypes.NameIdentifier, Guid.NewGuid().ToString()), }), new string[0] ); }
public SettingsViewModel( ITranslationsService translationsService, IFilePickerService filePickerService, IPackagingService packagingService, ISettingsService settingsService, IPlatformService platformService, IDialogService dialogService, IOpmlService opmlService) { Theme = string.Empty; Version = packagingService.Version; (LoadImages, NeedBanners) = (true, true); (FontSize, NotifyPeriod, MaxArticlesPerFeed) = (0, 0, 0); LeaveFeedback = new ObservableCommand(packagingService.LeaveFeedback); LeaveReview = new ObservableCommand(packagingService.LeaveReview); ImportOpml = new ObservableCommand(async() => { var stream = await filePickerService.PickFileForReadAsync(); await opmlService.ImportOpmlFeedsAsync(stream); }); ExportOpml = new ObservableCommand(async() => { var stream = await filePickerService.PickFileForWriteAsync(); await opmlService.ExportOpmlFeedsAsync(stream); }); Reset = new ObservableCommand(async() => { var response = await dialogService.ShowDialogForConfirmation( translationsService.Resolve("ResetAppNoRestore"), translationsService.Resolve("Notification")); if (response) { await platformService.ResetApp(); } }); Load = new ObservableCommand(async() => { await Task.WhenAll( StartTracking(NotifyPeriod, "NotifyPeriod", platformService.RegisterBackgroundTask), StartTracking(MaxArticlesPerFeed, "MaxArticlesPerFeed", o => Task.CompletedTask), StartTracking(NeedBanners, "NeedBanners", o => Task.CompletedTask), StartTracking(LoadImages, "LoadImages", o => Task.CompletedTask), StartTracking(FontSize, "FontSize", o => Task.CompletedTask), StartTracking(Theme, "Theme", platformService.RegisterTheme) ); }); async Task StartTracking <T>(ObservableProperty <T> property, string key, Func <T, Task> callback) where T : IConvertible { property.Value = await settingsService.GetAsync <T>(key); property.PropertyChanged += async(o, args) => { var value = property.Value; await callback.Invoke(value); await settingsService.SetAsync(key, value); }; } }
public InternationalizationFlow(ITranslationsService service) { _downloadTranslation = new RemoteActionsCallerForm(x => x.Add( () => _choose.ChosenValue, service.FetchTranslation, y => I18n.ConfigureImplementation( () => new TranslationWithFallbackI18n(_choose.ChosenValue.ToString(), y)))); _choose = new EnumChoiceForm <SupportedLang>( "Language choice", true, SupportedLang.EN, x => x.GetLangName(), x => { x.Choice.Widget.Style.Display = Display.Grid; x.Choice.Widget.Style.GridTemplateColumns = "auto 1fr"; x.Description.Widget.InnerHTML = @"For sake of simplicity you need to make explicit choice below. In a normal program, you would take current language either from logged in user property or from browser's Accept-Language header field. If you study source code you will see that messages eligible for translation are declared as: I18n.Translate(""Some message that should be localized"") Those messages can be easily found and translated within JSON file using <a target='_blank' href='https://github.com/d-p-y/oldschool-i18n'>OldSchool-I18n</a>"; x.Description.Widget.Style.WhiteSpace = WhiteSpace.Pre; x.Description.Widget.Style.PaddingBottom = "20px"; x.Description.Widget.ClassName = "grayedOut"; }); _welcomeDialog = new InformationalMessageForm(); }
public CompanyService( IUnitOfWork unitOfWork, ITranslationsService translationsService, IRepository <Company> repository, IEventAggregatorProvider eventAggregatorProvider) : base(unitOfWork, translationsService, repository) { _eventAggregatorProvider = eventAggregatorProvider; }
public EventGridService(ITranslationsService translationsService, IConsoleLoggerService consoleLoggerService, IMessageExpressionService messageExpressionService) { _consoleLoggerService = consoleLoggerService; _translationsService = translationsService; _messageExpressionService = messageExpressionService; }
public UnitTypeService( ICompanyService companyService, ITranslationsService translationsService, IUnitOfWork unitOfWork, IRepository <UnitType> repository) : base(unitOfWork, translationsService, repository) { _companyService = companyService; }
public ServiceBusPublisherService(IMessageExpressionService messageExpressionService, IConsoleLoggerService consoleLoggerService, ITranslationsService translationsService) { _messageExpressionService = messageExpressionService; _translationsService = translationsService; _consoleLoggerService = consoleLoggerService; }
public NewUtilityValidator( ICompanyService companyService, ITranslationsService translationsService) : base(companyService, translationsService) { RuleFor(x => x.Name).NotNull().NotEmpty().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.Name).Length(1, 60).WithMessage(string.Format(translationsService.GetTranslationByKey("validations.lengthBetween"), 1, 60)); RuleFor(x => x.Description).Length(0, 200).WithMessage(string.Format(translationsService.GetTranslationByKey("validations.lessThan"), 200)); }
public UwpHtmlParserService( ITranslationsService translationsService, IPlatformService platformService, ISettingsService settingsService) { _translationsService = translationsService; _platformService = platformService; _settingsService = settingsService; }
public BaseService( IUnitOfWork unitOfWork, ITranslationsService translationsService, IRepository <TEntity> repository) { _unitOfWork = unitOfWork; _translationsService = translationsService; _repository = repository; }
public MqttPublisherService(IMvxMessenger messageService, IMessageExpressionService messageExpressionService, IConsoleLoggerService consoleLoggerService, ITranslationsService translationsService) { _messageExpressionService = messageExpressionService; _messageService = messageService; _consoleLoggerService = consoleLoggerService; _translationsService = translationsService; }
public DirectMethodCommunicationViewModel(IDeviceService deviceService, ITranslationsService translationsService, IDeviceSettingDataService deviceSettingDataService, IMvxMessenger messageService) { _deviceService = deviceService; _translationsService = translationsService; _deviceSettingDataService = deviceSettingDataService; _directMethodStatusChangedMessageToken = messageService.Subscribe <DirectMethodStatusUpdatedMessage>(HandleDirectMethodStatusChanged); _deviceConnectionStatusChangedMessageToken = messageService.Subscribe <DeviceConnectionChangedMessage>(HandleDeviceConnectionStatus); }
public UwpLegacyFileService( IDialogService dialogService, IFavoritesService favoritesService, ICategoriesRepository sourcesRepository, ITranslationsService translationsService, ISerializationService serializationService) { _favoritesService = favoritesService; _serializationService = serializationService; _translationsService = translationsService; _categoriesRepository = sourcesRepository; _dialogService = dialogService; }
public CommonValidator(IService <T> service, ITranslationsService translationsService) : base(translationsService) { RuleFor(x => x.Id).NotNull().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.Id).Must(x => { if (x.HasValue) { return(service.Get(x.Value).Data == null); } return(true); }).WithMessage(translationsService.GetTranslationByKey("validations.duplicateId")); }
public WorksController( IAwardsService awardsService, IWorksService worksService, IEditionsService editionsService, IReviewsService reviewsService, ITranslationsService translationsService, IGenresService genresService) { _awardsService = awardsService; _worksService = worksService; _editionsService = editionsService; _reviewsService = reviewsService; _translationsService = translationsService; _genresService = genresService; }
protected CompanyDependentValidatorBase( ICompanyService companyService, ITranslationsService translationsService) : base(translationsService) { RuleFor(x => x.CompanyId).NotNull().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.CompanyId).Must(x => { if (x.HasValue) { var company = companyService.Get(x.Value); return(company.Data != null); } return(true); }).WithMessage(translationsService.GetTranslationByKey("validations.companyNotFound")); }
public ChannelsViewModel( ICategoriesRepository categoriesRepository, ITranslationsService translationsService, INavigationService navigationService, IFactoryService factoryService, IDialogService dialogService) { (IsEmpty, IsLoading) = (false, true); Items = new ObservableCollection <ChannelCategoryViewModel>(); OpenSearch = new ObservableCommand(navigationService.Navigate <SearchViewModel>); AddCategory = new ObservableCommand(async() => { var name = await dialogService.ShowDialogForResults( translationsService.Resolve("EnterNameOfNewCategory"), translationsService.Resolve("EnterNameOfNewCategoryTitle")); if (string.IsNullOrWhiteSpace(name)) { return; } var category = new Category { Title = name }; await categoriesRepository.InsertAsync(category); Items.Add(factoryService.CreateInstance < ChannelCategoryViewModel>(category, this)); }); Load = new ObservableCommand(async() => { IsLoading.Value = true; var categories = await categoriesRepository.GetAllAsync(); Items.Clear(); foreach (var category in categories) { Items.Add(factoryService.CreateInstance < ChannelCategoryViewModel>(category, this)); } IsEmpty.Value = Items.Count == 0; IsLoading.Value = false; // Subscribe on collection changed to perform items rearranging. Items.CollectionChanged += async(s, a) => { IsEmpty.Value = Items.Count == 0; var items = Items.Select(i => i.Category.Value); await categoriesRepository.RearrangeAsync(items); }; }); }
public NewUnitValidator( ICompanyService companyService, ITranslationsService translationsService, IUnitService unitService, IUnitTypeService unitTypeService) : base(companyService, translationsService) { RuleFor(x => x.ParentUnitId).Must(x => { if (x.HasValue) { var unit = unitService.Get(x.Value); return(unit.Data != null); } return(true); }).WithMessage(translationsService.GetTranslationByKey("validations.unitNotFound")); RuleFor(x => x.ParentUnitId).Must(x => { if (x.HasValue) { var unit = unitService.Get(x.Value); if (unit.Data != null) { return(unit.Data.IsContainer); } } return(true); }).WithMessage(translationsService.GetTranslationByKey("validations.parentUnitIsNotContainer")); RuleFor(x => x.TypeId).NotNull().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.TypeId).Must(x => { if (x.HasValue) { var type = unitTypeService.Get(x.Value); return(type.Data != null); } return(true); }).WithMessage(translationsService.GetTranslationByKey("validations.unitTypeNotFound")); RuleFor(x => x.Name).NotEmpty().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.Name).Must(x => !unitService.Get(n => n.Name.Equals(x)).Data.Any()) .WithMessage(translationsService.GetTranslationByKey("validations.duplicateName")); }
public MenuViewModel( ITranslationsService translationsService, INavigationService navigationService, IPlatformService platformService, ISettingsService settingsService) { SelectedIndex = 0; Items = new ObservableCollection <Tuple <string, object, ObservableCommand, Type> >(); Load = new ObservableCommand(async() => { await navigationService.Navigate <FeedViewModel>(); var theme = await settingsService.GetAsync <string>("Theme"); await platformService.RegisterTheme(theme); var freq = await settingsService.GetAsync <int>("NotifyPeriod"); await platformService.RegisterBackgroundTask(freq); await settingsService.SetAsync("LastFetched", DateTime.Now); }); CreateItem <FeedViewModel>("FeedViewMenuItem"); CreateItem <FaveViewModel>("FaveViewMenuItem"); CreateItem <ChannelsViewModel>("SourcesViewMenuItem"); CreateItem <SearchViewModel>("SearchViewMenuItem"); CreateItem <SettingsViewModel>("SettingsViewMenuItem"); navigationService.Navigated += (sender, args) => { var first = Items.FirstOrDefault(x => x.Item4 == args); if (first == null) { return; } SelectedIndex.Value = Items.IndexOf(first); }; void CreateItem <T>(string key) where T : class { var type = typeof(T); var command = new ObservableCommand(navigationService.Navigate <T>); var translation = translationsService.Resolve(key); var icon = navigationService.Icons[type]; var tuple = (translation, icon, command, type).ToTuple(); Items.Add(tuple); } }
public MainMenuFlow(ISomeService someService, ITranslationsService translationsService, IHttpRequester httpRequester) { IFormRenderer <HTMLElement> CreateRenderer() => _baseRenderer.CreateRendererWithBase( new ElementWrapperFormCanvas( Toolkit.BaseFormCanvasTitleStrategy, _mainMenuFormView.BodyPanel.Widget, Toolkit.DefaultExitButtonBuilder, Toolkit.DefaultLayoutMode)); _aboutMsg = new InformationalMessageForm( new InformationalMessageFormView(TextType.TreatAsHtml), "<b>Philadelphia Toolkit Demo</b><br>by TODO IT spółka z o.o.", "About program"); _aboutMsg.Ended += (x, _) => _lastRenderer.Remove(x); _licensesInfoMsg = new InformationalMessageForm( new InformationalMessageFormView(TextType.TreatAsHtml), OpenSourceLicensesText.OpenSourceLicensesHtml, I18n.Translate("Used open source licensed programs and libraries")); _licensesInfoMsg.Ended += (x, _) => _lastRenderer.Remove(x); var menuItems = new List <MenuItemUserModel> { CreateSubTree("Features", CreateLocalLeaf( "Server-sent events", () => new SseDemoFlow(someService).Run(CreateRenderer())), CreateLocalLeaf( "Forms navigation", () => new NavigationProgram().Run(CreateRenderer())), CreateLocalLeaf( "Internationalization", () => new InternationalizationFlow(translationsService).Run(CreateRenderer()))), CreateSubTree("Data validation", CreateLocalLeaf( "Simplest", () => new ValidationProgram().Run(CreateRenderer())), CreateLocalLeaf( "Tabbed view indicator", () => new TabbedViewValidationFlow().Run(CreateRenderer())), CreateLocalLeaf( "File uploads", () => new UploaderDemoFlow(someService, httpRequester).Run(CreateRenderer()))), CreateSubTree("Widgets", CreateLocalLeaf( "Databound datagrid", () => new DataboundDatagridProgram(someService).Run(CreateRenderer())), CreateLocalLeaf( "Datetime pickers", () => new DateTimeDemoProgram().Run(CreateRenderer())), CreateLocalLeaf( "Dropdowns", () => new DropdownsProgram().Run(CreateRenderer())), CreateLocalLeaf( "Master details", () => new MasterDetailsProgram(someService).Run(CreateRenderer())), CreateLocalLeaf( "Flexible layout", () => new FlexibleLayoutFlow().Run(CreateRenderer()))), CreateSubTree("Help", CreateLocalLeaf( "About program", () => { _lastRenderer = CreateRenderer(); _lastRenderer.AddPopup(_aboutMsg); }), CreateLocalLeaf( "Open source licenses", () => { _lastRenderer = CreateRenderer(); _lastRenderer.AddPopup(_licensesInfoMsg); }) ) }; //TODO dropdown with not-legal-anymore/scratched value //TODO add I18n demo _mainMenuFormView = new HorizontalLinksMenuFormView(); _mainMenuForm = new MenuForm(_mainMenuFormView, menuItems); }
public TranslationsController(UserManager<ApplicationUser> userManager, ITranslationsService translationsService) : base(userManager) { _translationsService = translationsService; }
public ArticleViewModel( ICategoriesRepository categoriesRepository, ITranslationsService translationsService, INavigationService navigationService, IFavoritesService favoritesService, ISettingsService settingsService, IPlatformService platformService, IDialogService dialogService, Article article) { Title = article.Title; Feed = article.FeedTitle; Content = article.Content; PublishedDate = article.PublishedDate; IsFavorite = article.Fave; IsRead = article.Read; Open = new ObservableCommand(() => navigationService.Navigate <ArticleViewModel>(this)); Image = new ObservableProperty <string>(async() => { var shouldLoadImages = await settingsService.GetAsync <bool>("LoadImages"); return(shouldLoadImages ? article.ImageUri : null); }); Share = new ObservableCommand(() => { var shareMessage = string.Concat( article.Title, Environment.NewLine, article.Uri, Environment.NewLine, "via myFeed for Windows Universal"); return(platformService.Share(shareMessage)); }); CopyLink = new ObservableCommand(async() => { await platformService.CopyTextToClipboard(article.Uri); await dialogService.ShowDialog( translationsService.Resolve("CopyLinkSuccess"), translationsService.Resolve("SettingsNotification")); }); LaunchUri = new ObservableCommand(async() => { if (Uri.IsWellFormedUriString(article.Uri, UriKind.Absolute)) { await platformService.LaunchUri(new Uri(article.Uri)); } }); MarkRead = new ObservableCommand(async() => { IsRead.Value = article.Read = !IsRead.Value; await categoriesRepository.UpdateArticleAsync(article); }); MarkFavorite = new ObservableCommand(async() => { IsFavorite.Value = !IsFavorite.Value; if (IsFavorite.Value) { await favoritesService.Insert(article); } else { await favoritesService.Remove(article); } }); }
public NewCompanyValidator(IRepository <Model.Entities.Company> companyRepository, ITranslationsService translationsService) : base(translationsService) { CascadeMode = CascadeMode.StopOnFirstFailure; RuleFor(x => x.Name).NotEmpty().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.Name).Length(6, 60).WithMessage(string.Format(translationsService.GetTranslationByKey("validations.lengthBetween"), 6, 60)); RuleFor(x => x.Name).Must(x => !companyRepository.GetAll(n => n.Name.Equals(x)).Any()) .WithMessage(translationsService.GetTranslationByKey("validations.duplicateName")); RuleFor(x => x.Phone).NotEmpty().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.Phone).Must(x => new PhoneAttribute().IsValid(x)).WithMessage(translationsService.GetTranslationByKey("validations.invalidPhone")); RuleFor(x => x.Phone).Must(x => !companyRepository.GetAll(n => n.Phone.Equals(x)).Any()) .WithMessage(translationsService.GetTranslationByKey("validations.duplicatePhone")); RuleFor(x => x.Country).NotEmpty().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.Country).Must(x => { return(new CountriesProvider().Countries.Any(y => y.Code == x)); } ).WithMessage(translationsService.GetTranslationByKey("validations.invalidCountryCode")); RuleFor(x => x.Email).NotEmpty().WithMessage(translationsService.GetTranslationByKey("validations.required")); RuleFor(x => x.Email) .Must(x => new EmailAddressAttribute().IsValid(x)) .WithMessage(translationsService.GetTranslationByKey("validations.invalidEmail")); RuleFor(x => x.Email) .Must(email => !companyRepository.GetAll(cmp => cmp.Email == email).Any()) .WithMessage(translationsService.GetTranslationByKey("validations.duplicateEmail")); }
public ChannelCategoryViewModel( ICategoriesRepository categoriesRepository, ITranslationsService translationsService, IFactoryService factoryService, IDialogService dialogService, ChannelsViewModel channelsViewModel, Category category) { Category = category; Title = category.Title; SourceUri = string.Empty; Items = new ObservableCollection <ChannelViewModel>(); RenameCategory = new ObservableCommand(async() => { var name = await dialogService.ShowDialogForResults( translationsService.Resolve("EnterNameOfNewCategory"), translationsService.Resolve("EnterNameOfNewCategoryTitle")); if (string.IsNullOrWhiteSpace(name)) { return; } category.Title = name; await categoriesRepository.UpdateAsync(category); category.Title = Title.Value = name; }); RemoveCategory = new ObservableCommand(async() => { var shouldDelete = await dialogService.ShowDialogForConfirmation( translationsService.Resolve("DeleteCategory"), translationsService.Resolve("DeleteElement")); if (!shouldDelete) { return; } await categoriesRepository.RemoveAsync(category); channelsViewModel.Items.Remove(this); }); AddSource = new ObservableCommand(async() => { var sourceUri = SourceUri.Value; if (string.IsNullOrWhiteSpace(sourceUri) || !Uri.IsWellFormedUriString(sourceUri, UriKind.Absolute)) { return; } SourceUri.Value = string.Empty; var model = new Channel { Uri = sourceUri, Notify = true }; await categoriesRepository.InsertChannelAsync(category, model); Items.Add(factoryService.CreateInstance < ChannelViewModel>(model, this)); }); Load = new ObservableCommand(() => { Items.Clear(); foreach (var channel in category.Channels) { Items.Add(factoryService.CreateInstance < ChannelViewModel>(channel, this)); } }); }
protected BaseValidator(ITranslationsService translationsService) { _translationsService = translationsService; }
public NewsController(ICrmService _crmService, ISettingsProvider _settingsProvider, ITranslationsService _translations) { settingsProvider = _settingsProvider; this.translations = _translations; crmService = _crmService; }
public FilePickerService(ITranslationsService translationsService) { _translationsService = translationsService; }
public TranslatedPokemonFeature(IPokeService pokeService, ITranslationsService translationsService) { this.pokeService = pokeService; this.translationsService = translationsService; }
public TranslationController(ITranslationsService service) { this.service = service; }
public UwpDialogService(ITranslationsService translationsService) => _translationsService = translationsService;
public WorkItemsController(IWorkItemTrackerServiceRepository workItemTrackerServiceRepository, ITranslationsService translationsService, IUrlHelper urlHelper) { _workItemTrackerServiceRepository = workItemTrackerServiceRepository; _translationsService = translationsService; Url = urlHelper; }