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

Commit 7fa3ec2

Browse files
author
Jasmine
committed
adding missed constuctor back
1 parent c081995 commit 7fa3ec2

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/GitHub.VisualStudio/Base/MenuBase.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,47 @@ protected MenuBase(IServiceProvider serviceProvider, ISimpleApiClientFactory api
4646
this.apiFactory = apiFactory;
4747
}
4848

49+
protected MenuBase(IServiceProvider serviceProvider)
50+
{
51+
this.serviceProvider = serviceProvider;
52+
}
53+
54+
protected ISimpleRepositoryModel GetActiveRepo()
55+
{
56+
var activeRepo = ServiceProvider.GetExportedValue<ITeamExplorerServiceHolder>()?.ActiveRepo;
57+
// activeRepo can be null at this point because it is set elsewhere as the result of async operation that may not have completed yet.
58+
if (activeRepo == null)
59+
{
60+
var path = ServiceProvider.GetExportedValue<IVSServices>()?.GetActiveRepoPath() ?? String.Empty;
61+
try
62+
{
63+
activeRepo = !string.IsNullOrEmpty(path) ? new SimpleRepositoryModel(path) : null;
64+
}
65+
catch (Exception ex)
66+
{
67+
VsOutputLogger.WriteLine(string.Format(CultureInfo.CurrentCulture, "Error loading the repository from '{0}'. {1}", path, ex));
68+
}
69+
}
70+
return activeRepo;
71+
}
72+
73+
protected void StartFlow(UIControllerFlow controllerFlow)
74+
{
75+
var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>();
76+
Debug.Assert(uiProvider != null, "MenuBase:StartFlow:No UIProvider available.");
77+
if (uiProvider == null)
78+
return;
79+
80+
IConnection connection = null;
81+
if (controllerFlow != UIControllerFlow.Authentication)
82+
{
83+
var activeRepo = GetActiveRepo();
84+
connection = ServiceProvider.GetExportedValue<IConnectionManager>()?.Connections
85+
.FirstOrDefault(c => activeRepo?.CloneUrl?.RepositoryName != null && c.HostAddress.Equals(HostAddress.Create(activeRepo.CloneUrl)));
86+
}
87+
uiProvider.RunUI(controllerFlow, connection);
88+
}
89+
4990
void RefreshRepo()
5091
{
5192
ActiveRepo = ServiceProvider.GetExportedValue<ITeamExplorerServiceHolder>().ActiveRepo;

0 commit comments

Comments
 (0)