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

Commit 6034643

Browse files
committed
Added IGlobalConnection.
This services the same purpose as `IConnectionRepositoryHostMap` served when `RepositoryHost` was still around: to provide access to the globally registered connection.
1 parent 95cd0b1 commit 6034643

18 files changed

+82
-22
lines changed

src/GitHub.App/GitHub.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
<Compile Include="Models\IssueCommentModel.cs" />
132132
<Compile Include="Models\PullRequestReviewCommentModel.cs" />
133133
<Compile Include="Models\PullRequestDetailArgument.cs" />
134+
<Compile Include="Services\GlobalConnection.cs" />
134135
<Compile Include="Services\LocalRepositories.cs" />
135136
<Compile Include="ViewModels\ViewModelBase.cs" />
136137
<Compile Include="Caches\CacheIndex.cs" />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.ComponentModel.Composition;
3+
using GitHub.Models;
4+
using GitHub.Services;
5+
6+
namespace GitHub.App.Services
7+
{
8+
[Export(typeof(IGlobalConnection))]
9+
[PartCreationPolicy(CreationPolicy.Shared)]
10+
public class GlobalConnection : IGlobalConnection
11+
{
12+
readonly IGitHubServiceProvider serviceProvider;
13+
14+
[ImportingConstructor]
15+
public GlobalConnection(IGitHubServiceProvider serviceProvider)
16+
{
17+
this.serviceProvider = serviceProvider;
18+
}
19+
20+
public IConnection Get() => serviceProvider.TryGetService<IConnection>();
21+
}
22+
}

src/GitHub.App/ViewModels/GistCreationViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public class GistCreationViewModel : DialogViewModelBase, IGistCreationViewModel
3232

3333
[ImportingConstructor]
3434
GistCreationViewModel(
35-
IConnection connection,
35+
IGlobalConnection connection,
3636
IModelServiceFactory modelServiceFactory,
3737
ISelectedTextProvider selectedTextProvider,
3838
IGistPublishService gistPublishService,
3939
INotificationService notificationService,
4040
IUsageTracker usageTracker)
41-
: this(connection, modelServiceFactory, selectedTextProvider, gistPublishService, usageTracker)
41+
: this(connection.Get(), modelServiceFactory, selectedTextProvider, gistPublishService, usageTracker)
4242
{
4343
Guard.ArgumentNotNull(connection, nameof(connection));
4444
Guard.ArgumentNotNull(selectedTextProvider, nameof(selectedTextProvider));

src/GitHub.App/ViewModels/LoginControlViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using GitHub.Authentication;
77
using GitHub.Exports;
88
using GitHub.Extensions.Reactive;
9-
using GitHub.Models;
109
using GitHub.Primitives;
1110
using GitHub.Services;
1211
using ReactiveUI;

src/GitHub.App/ViewModels/LoginTabViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using GitHub.Extensions;
1111
using GitHub.Extensions.Reactive;
1212
using GitHub.Info;
13-
using GitHub.Models;
1413
using GitHub.Primitives;
1514
using GitHub.Services;
1615
using GitHub.Validation;

src/GitHub.App/ViewModels/LoginToGitHubForEnterpriseViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using GitHub.Authentication;
88
using GitHub.Extensions;
99
using GitHub.Info;
10-
using GitHub.Models;
1110
using GitHub.Primitives;
1211
using GitHub.Services;
1312
using GitHub.Validation;

src/GitHub.App/ViewModels/LoginToGitHubViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Reactive.Linq;
55
using GitHub.Authentication;
66
using GitHub.Info;
7-
using GitHub.Models;
87
using GitHub.Primitives;
98
using GitHub.Services;
109
using ReactiveUI;

src/GitHub.App/ViewModels/NotAGitHubRepositoryViewModel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System;
22
using System.ComponentModel.Composition;
33
using GitHub.Exports;
4-
using GitHub.Models;
54
using GitHub.Services;
6-
using GitHub.UI;
75
using ReactiveUI;
86

97
namespace GitHub.ViewModels

src/GitHub.App/ViewModels/PanePageViewModelBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using ReactiveUI;
2-
using GitHub.UI;
32

43
namespace GitHub.ViewModels
54
{

src/GitHub.App/ViewModels/PullRequestCreationViewModel.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,18 @@ public class PullRequestCreationViewModel : DialogViewModelBase, IPullRequestCre
3232

3333
readonly ObservableAsPropertyHelper<IRemoteRepositoryModel> githubRepository;
3434
readonly ObservableAsPropertyHelper<bool> isExecuting;
35-
readonly IConnection connection;
3635
readonly IModelService modelService;
3736
readonly IObservable<IRemoteRepositoryModel> githubObs;
3837
readonly CompositeDisposable disposables = new CompositeDisposable();
3938
readonly ILocalRepositoryModel activeLocalRepo;
4039

4140
[ImportingConstructor]
4241
PullRequestCreationViewModel(
43-
IConnection connection,
42+
IGlobalConnection connection,
4443
IModelServiceFactory modelServiceFactory,
4544
ITeamExplorerServiceHolder teservice,
4645
IPullRequestService service, INotificationService notifications)
47-
: this(connection, modelServiceFactory, teservice?.ActiveRepo, service, notifications)
46+
: this(connection.Get(), modelServiceFactory, teservice?.ActiveRepo, service, notifications)
4847
{}
4948

5049
public PullRequestCreationViewModel(
@@ -60,7 +59,6 @@ public PullRequestCreationViewModel(
6059
Guard.ArgumentNotNull(service, nameof(service));
6160
Guard.ArgumentNotNull(notifications, nameof(notifications));
6261

63-
this.connection = connection;
6462
activeLocalRepo = activeRepo;
6563
modelService = modelServiceFactory.CreateBlocking(connection);
6664

0 commit comments

Comments
 (0)