in sources/Google.Solutions.IapDesktop.Extensions.Session/InitializeSessionExtension.cs [176:310]
public InitializeSessionExtension(IServiceProvider serviceProvider)
{
this.serviceProvider = serviceProvider;
var mainForm = serviceProvider.GetService<IMainWindow>();
//
// Register protocols.
//
var protocolRegistry = serviceProvider.GetService<ProtocolRegistry>();
protocolRegistry.RegisterProtocol(
new AppProtocol(
"SQL Server Management Studio",
Enumerable.Empty<ITrait>(),
Ssms.DefaultServerPort,
null,
new SsmsClient()));
_ = LoadAndRegisterAppProtocolsAsync(mainForm, protocolRegistry);
//
// Let this extension handle all URL activations.
//
var connectCommands = new ConnectCommands(
serviceProvider.GetService<UrlCommands>(),
serviceProvider.GetService<ISessionContextFactory>(),
serviceProvider.GetService<IProjectWorkspace>(),
serviceProvider.GetService<ISessionFactory>(),
serviceProvider.GetService<ISessionBroker>());
Debug.Assert(serviceProvider
.GetService<UrlCommands>()
.LaunchRdpUrl.QueryState(new IapRdpUrl(
new InstanceLocator("project", "zone", "name"),
new NameValueCollection())) == CommandState.Enabled,
"URL command installed");
//
// Connect.
//
var projectExplorer = serviceProvider.GetService<IProjectExplorer>();
projectExplorer.ContextMenuCommands.AddCommand(
connectCommands.ContextMenuActivateOrConnectInstance,
0);
projectExplorer.ContextMenuCommands.AddCommand(
connectCommands.ContextMenuConnectRdpAsUser,
1);
projectExplorer.ContextMenuCommands.AddCommand(
connectCommands.ContextMenuConnectSshInNewTerminal,
2);
//
// App commands.
//
var appCommands = serviceProvider.GetService<AppCommands>();
var connectWithClientCommands = projectExplorer.ContextMenuCommands.AddCommandGroup(
appCommands.ContextMenuConnectWithClient,
3);
var connectTunnelCommands = projectExplorer.ContextMenuCommands.AddCommandGroup(
appCommands.ContextMenuConnectTunnel,
4);
projectExplorer.ToolbarCommands.AddCommand(
connectCommands.ToolbarActivateOrConnectInstance);
//
// Generate credentials (Windows/RDP only).
//
var credentialCommands = new CredentialCommands(
serviceProvider.GetService<IConnectionSettingsService>(),
serviceProvider.GetService<IRdpCredentialEditorFactory>());
projectExplorer.ContextMenuCommands.AddCommand(
credentialCommands.ContextMenuNewCredentials,
5);
projectExplorer.ToolbarCommands.AddCommand(
credentialCommands.ToolbarNewCredentials);
//
// Connection settings.
//
var connectionSettingsCommands = serviceProvider.GetService<ConnectionSettingsCommands>();
projectExplorer.ContextMenuCommands.AddCommand(
connectionSettingsCommands.ContextMenuOpen,
6);
projectExplorer.ToolbarCommands.AddCommand(
connectionSettingsCommands.ToolbarOpen,
3);
//
// Authorized keys.
//
var authorizedKeyCommands = serviceProvider.GetService<AuthorizedPublicKeysCommands>();
projectExplorer.ContextMenuCommands.AddCommand(
authorizedKeyCommands.ContextMenuOpen,
11);
#if DEBUG
projectExplorer.ContextMenuCommands.AddCommand(
serviceProvider.GetService<DiagnosticsCommands>().GenerateHtmlPage);
#endif
//
// View menu.
//
var tunnelsViewCommands = serviceProvider.GetService<TunnelsViewCommands>();
mainForm.ViewMenu.AddCommand(
tunnelsViewCommands.WindowMenuOpen,
1);
mainForm.ViewMenu.AddCommand(authorizedKeyCommands.WindowMenuOpen);
//
// Session menu.
//
var sessionBroker = serviceProvider.GetService<ISessionBroker>();
var sessionCommands = new SessionCommands(sessionBroker);
var menu = sessionBroker.SessionMenu;
menu.AddCommand(sessionCommands.EnterFullScreenOnSingleScreen);
menu.AddCommand(sessionCommands.EnterFullScreenOnAllScreens);
menu.AddCommand(connectCommands.DuplicateSession);
menu.AddSeparator();
menu.AddCommand(sessionCommands.TransferFiles);
menu.AddCommand(sessionCommands.TypeClipboardText);
menu.AddCommand(sessionCommands.ShowSecurityScreen);
menu.AddCommand(sessionCommands.ShowTaskManager);
menu.AddSeparator();
menu.AddCommand(sessionCommands.Logoff);
menu.AddCommand(sessionCommands.Reconnect);
menu.AddSeparator();
menu.AddCommand(sessionCommands.Close);
menu.AddCommand(sessionCommands.CloseAll);
menu.AddCommand(sessionCommands.CloseAllButThis);
}