Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 75fc407

Browse files
committed
🎨 Sprinkle the code with some C# 6 loveliness
1 parent d95da0a commit 75fc407

File tree

5 files changed

+26
-39
lines changed

5 files changed

+26
-39
lines changed

src/GitHub.App/ViewModels/LoginTabViewModel.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using GitHub.Validation;
1414
using NLog;
1515
using NullGuard;
16+
using Octokit;
1617
using ReactiveUI;
1718

1819
namespace GitHub.ViewModels
@@ -72,13 +73,20 @@ protected LoginTabViewModel(IRepositoryHosts repositoryHosts, IVisualStudioBrows
7273
return Observable.Return(Unit.Default);
7374
});
7475
}
75-
protected IRepositoryHosts RepositoryHosts { get; private set; }
76+
protected IRepositoryHosts RepositoryHosts { get; }
7677
protected abstract Uri BaseUri { get; }
77-
public IReactiveCommand<Unit> SignUp { get; private set; }
78+
public IReactiveCommand<Unit> SignUp { get; }
7879

79-
public IReactiveCommand<AuthenticationResult> Login { get; private set; }
80-
public IReactiveCommand<Unit> Reset { get; private set; }
81-
public IReactiveCommand<Unit> NavigateForgotPassword { get; private set; }
80+
public IReactiveCommand<AuthenticationResult> Login { get; }
81+
public IReactiveCommand<Unit> Reset { get; }
82+
public IReactiveCommand<Unit> NavigateForgotPassword { get; }
83+
84+
string loginFailedMessage = "Check your username and password, then try again";
85+
public string LoginFailedMessage
86+
{
87+
get { return loginFailedMessage; }
88+
set { this.RaiseAndSetIfChanged(ref loginFailedMessage, value); }
89+
}
8290

8391
string usernameOrEmail;
8492
[AllowNull]

src/GitHub.App/ViewModels/LoginToGitHubForEnterpriseViewModel.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class LoginToGitHubForEnterpriseViewModel : LoginTabViewModel, ILoginToGi
2121
[ImportingConstructor]
2222
public LoginToGitHubForEnterpriseViewModel(IRepositoryHosts hosts, IVisualStudioBrowser browser) : base(hosts, browser)
2323
{
24-
enterpriseUrlValidator = ReactivePropertyValidator.For(this, x => x.EnterpriseUrl)
24+
EnterpriseUrlValidator = ReactivePropertyValidator.For(this, x => x.EnterpriseUrl)
2525
.IfNullOrEmpty("Please enter an Enterprise URL")
2626
.IfNotUri("Please enter a valid Enterprise URL")
2727
.IfGitHubDotComHost("Not an Enterprise server. Please enter an Enterprise URL");
@@ -55,24 +55,13 @@ public string EnterpriseUrl
5555
set { this.RaiseAndSetIfChanged(ref enterpriseUrl, value); }
5656
}
5757

58-
readonly ReactivePropertyValidator enterpriseUrlValidator;
59-
public ReactivePropertyValidator EnterpriseUrlValidator
60-
{
61-
get { return enterpriseUrlValidator; }
62-
}
58+
public ReactivePropertyValidator EnterpriseUrlValidator { get; }
6359

64-
protected override Uri BaseUri
65-
{
66-
get
67-
{
68-
return new Uri(EnterpriseUrl);
69-
}
70-
}
60+
protected override Uri BaseUri => new Uri(EnterpriseUrl);
7161

7262
public IReactiveCommand<Unit> NavigateLearnMore
7363
{
7464
get;
75-
private set;
7665
}
7766

7867
protected override async Task ResetValidation()

src/GitHub.App/ViewModels/LoginToGitHubViewModel.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ namespace GitHub.ViewModels
1515
[PartCreationPolicy(CreationPolicy.NonShared)]
1616
public class LoginToGitHubViewModel : LoginTabViewModel, ILoginToGitHubViewModel
1717
{
18-
readonly Uri baseUri;
19-
2018
[ImportingConstructor]
2119
public LoginToGitHubViewModel(IRepositoryHosts repositoryHosts, IVisualStudioBrowser browser)
2220
: base(repositoryHosts, browser)
2321
{
24-
baseUri = HostAddress.GitHubDotComHostAddress.WebUri;
22+
BaseUri = HostAddress.GitHubDotComHostAddress.WebUri;
2523

2624
NavigatePricing = ReactiveCommand.CreateAsyncObservable(_ =>
2725
{
@@ -31,16 +29,13 @@ public LoginToGitHubViewModel(IRepositoryHosts repositoryHosts, IVisualStudioBro
3129
});
3230
}
3331

34-
public IReactiveCommand<Unit> NavigatePricing { get; private set; }
32+
public IReactiveCommand<Unit> NavigatePricing { get; }
3533

36-
protected override Uri BaseUri
37-
{
38-
get { return baseUri; }
39-
}
34+
protected override Uri BaseUri { get; }
4035

41-
protected override IObservable<AuthenticationResult> LogIn(object args)
42-
{
43-
return LogInToHost(HostAddress.GitHubDotComHostAddress);
44-
}
36+
protected override IObservable<AuthenticationResult> LogIn(object args)
37+
{
38+
return LogInToHost(HostAddress.GitHubDotComHostAddress);
4539
}
40+
}
4641
}

src/GitHub.VisualStudio/UI/Views/Controls/LoginControl.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Linq;
32
using System.Reactive.Linq;
43
using System.Windows;
54
using System.Windows.Input;
@@ -63,6 +62,7 @@ void SetupDotComBindings(Action<IDisposable> d)
6362
d(this.OneWayBind(ViewModel, vm => vm.GitHubLogin.NavigatePricing, v => v.pricingLink.Command));
6463

6564
d(this.OneWayBind(ViewModel, vm => vm.GitHubLogin.ShowLogInFailedError, v => v.dotComLoginFailedMessage.Visibility));
65+
d(this.OneWayBind(ViewModel, vm => vm.GitHubLogin.LoginFailedMessage, v => v.dotComLoginFailedMessage.Message));
6666
d(this.OneWayBind(ViewModel, vm => vm.GitHubLogin.ShowConnectingToHostFailed, v => v.dotComConnectionFailedMessage.Visibility));
6767
}
6868

@@ -86,6 +86,7 @@ void SetupEnterpriseBindings(Action<IDisposable> d)
8686
d(this.OneWayBind(ViewModel, vm => vm.EnterpriseLogin.NavigateLearnMore, v => v.learnMoreLink.Command));
8787

8888
d(this.OneWayBind(ViewModel, vm => vm.EnterpriseLogin.ShowLogInFailedError, v => v.enterpriseLoginFailedMessage.Visibility));
89+
d(this.OneWayBind(ViewModel, vm => vm.EnterpriseLogin.LoginFailedMessage, v => v.enterpriseLoginFailedMessage.Message));
8990
d(this.OneWayBind(ViewModel, vm => vm.EnterpriseLogin.ShowConnectingToHostFailed, v => v.enterpriseConnectingFailedMessage.Visibility));
9091
}
9192

src/UnitTests/Helpers/TestBaseClass.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using EntryExitDecoratorInterfaces;
7-
using GitHub.VisualStudio;
1+
using EntryExitDecoratorInterfaces;
82

93
/// <summary>
104
/// This base class will get its methods called by the most-derived

0 commit comments

Comments
 (0)