async Task CheckLogin() { // this is not a github repo, or it hasn't been published yet if (ActiveRepo == null || ActiveRepoUri == null) { return; } var isgithub = await IsAGitHubRepo(); if (!isgithub) { return; } vsServices.ClearNotifications(); var add = HostAddress.Create(ActiveRepoUri); bool loggedIn = await connectionManager.IsLoggedIn(hosts, add); if (!loggedIn) { var msg = string.Format(CultureInfo.CurrentUICulture, Resources.NotLoggedInMessage, add.Title, add.Title); vsServices.ShowMessage( msg, new RelayCommand(() => StartFlow(UIControllerFlow.Authentication)) ); } }
void InitializeValidation() { var nonNullRepositoryName = this.WhenAny( x => x.RepositoryName, x => x.Value) .WhereNotNull(); RepositoryNameValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName) .IfNullOrEmpty("Please enter a repository name") .IfTrue(x => x.Length > 100, "Repository name must be fewer than 100 characters"); SafeRepositoryNameWarningValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName) .Add(repoName => { var parsedReference = GetSafeRepositoryName(repoName); return(parsedReference != repoName ? "Will be created as " + parsedReference : null); }); this.WhenAny(x => x.SafeRepositoryNameWarningValidator.ValidationResult, x => x.Value) .WhereNotNull() // When this is instantiated, it sends a null result. .Select(result => result?.Message) .Subscribe(message => { if (!string.IsNullOrEmpty(message)) { vsServices.ShowWarning(message); } else { vsServices.ClearNotifications(); } }); }
void InitializeValidation() { var nonNullRepositoryName = this.WhenAny( x => x.RepositoryName, x => x.Value) .WhereNotNull(); RepositoryNameValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName) .IfNullOrEmpty(Resources.RepositoryNameValidatorEmpty) .IfTrue(x => x.Length > 100, Resources.RepositoryNameValidatorTooLong); SafeRepositoryNameWarningValidator = ReactivePropertyValidator.ForObservable(nonNullRepositoryName) .Add(repoName => { var parsedReference = GetSafeRepositoryName(repoName); return(parsedReference != repoName ? String.Format(CultureInfo.CurrentCulture, Resources.SafeRepositoryNameWarning, parsedReference) : null); }); this.WhenAny(x => x.SafeRepositoryNameWarningValidator.ValidationResult, x => x.Value) .WhereNotNull() // When this is instantiated, it sends a null result. .Select(result => result?.Message) .Subscribe(message => { if (!string.IsNullOrEmpty(message)) { vsServices.ShowWarning(message); } else { vsServices.ClearNotifications(); } }); }