mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
made one of the methods for the connectioninitiator non-static (they should eventually all be non-static).
This change was made to making testing easier (make connectioninitiator mockable)
This commit is contained in:
@@ -12,7 +12,7 @@ using TabPage = Crownwood.Magic.Controls.TabPage;
|
||||
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
public static class ConnectionInitiator
|
||||
public class ConnectionInitiator : IConnectionInitiator
|
||||
{
|
||||
public static void OpenConnection(ContainerInfo containerInfo, ConnectionInfo.Force force = ConnectionInfo.Force.None)
|
||||
{
|
||||
@@ -33,7 +33,7 @@ namespace mRemoteNG.Connection
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenConnection(ConnectionInfo connectionInfo)
|
||||
public void OpenConnection(ConnectionInfo connectionInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
7
mRemoteV1/Connection/IConnectionInitiator.cs
Normal file
7
mRemoteV1/Connection/IConnectionInitiator.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
public interface IConnectionInitiator
|
||||
{
|
||||
void OpenConnection(ConnectionInfo connectionInfo);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace mRemoteNG.Tools
|
||||
{
|
||||
public class ExternalTool
|
||||
{
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
#region Public Properties
|
||||
public string DisplayName { get; set; }
|
||||
public string FileName { get; set; }
|
||||
@@ -80,7 +81,7 @@ namespace mRemoteNG.Tools
|
||||
try
|
||||
{
|
||||
var newConnectionInfo = BuildConnectionInfoForIntegratedApp();
|
||||
ConnectionInitiator.OpenConnection(newConnectionInfo);
|
||||
_connectionInitiator.OpenConnection(newConnectionInfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -15,8 +15,10 @@ namespace mRemoteNG.Tools
|
||||
private NotifyIcon _nI;
|
||||
private ContextMenuStrip _cMen;
|
||||
private ToolStripMenuItem _cMenCons;
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
|
||||
public bool Disposed { get; set; }
|
||||
|
||||
public bool Disposed { get; set; }
|
||||
|
||||
public NotificationAreaIcon()
|
||||
{
|
||||
@@ -124,7 +126,7 @@ namespace mRemoteNG.Tools
|
||||
{
|
||||
ShowForm();
|
||||
}
|
||||
ConnectionInitiator.OpenConnection((ConnectionInfo)((Control)sender).Tag);
|
||||
_connectionInitiator.OpenConnection((ConnectionInfo)((Control)sender).Tag);
|
||||
}
|
||||
|
||||
private void cMenExit_Click(Object sender, EventArgs e)
|
||||
|
||||
@@ -8,6 +8,9 @@ namespace mRemoteNG.Tree
|
||||
{
|
||||
public class PreviousSessionOpener : IConnectionTreeDelegate
|
||||
{
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
|
||||
|
||||
public void Execute(ConnectionTree connectionTree)
|
||||
{
|
||||
if (!Settings.Default.OpenConsFromLastSession || Settings.Default.NoReconnect) return;
|
||||
@@ -15,7 +18,7 @@ namespace mRemoteNG.Tree
|
||||
var previouslyOpenedConnections = connectionInfoList.Where(item => item.PleaseConnect);
|
||||
foreach (var connectionInfo in previouslyOpenedConnections)
|
||||
{
|
||||
ConnectionInitiator.OpenConnection(connectionInfo);
|
||||
_connectionInitiator.OpenConnection(connectionInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace mRemoteNG.UI.Forms
|
||||
private ConnectionInfo _selectedConnection;
|
||||
private SystemMenu _systemMenu;
|
||||
private ConnectionTreeWindow ConnectionTreeWindow { get; set; }
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -936,14 +938,14 @@ namespace mRemoteNG.UI.Forms
|
||||
btnConnections.DropDownItems.AddRange(rootMenuItems);
|
||||
}
|
||||
|
||||
private static void ConnectionsMenuItem_MouseUp(object sender, MouseEventArgs e)
|
||||
private void ConnectionsMenuItem_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button != MouseButtons.Left) return;
|
||||
if (((ToolStripMenuItem) sender).Tag is ContainerInfo) return;
|
||||
var tag = ((ToolStripMenuItem)sender).Tag as ConnectionInfo;
|
||||
if (tag != null)
|
||||
{
|
||||
ConnectionInitiator.OpenConnection(tag);
|
||||
_connectionInitiator.OpenConnection(tag);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace mRemoteNG.UI.Window
|
||||
public partial class ConnectionTreeWindow
|
||||
{
|
||||
private readonly ConnectionContextMenu _contextMenu;
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
|
||||
|
||||
public ConnectionInfo SelectedNode => olvConnections.SelectedNode;
|
||||
|
||||
@@ -276,7 +278,7 @@ namespace mRemoteNG.UI.Window
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
e.Handled = true;
|
||||
ConnectionInitiator.OpenConnection(SelectedNode);
|
||||
_connectionInitiator.OpenConnection(SelectedNode);
|
||||
}
|
||||
else if (e.Control && e.KeyCode == Keys.F)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace mRemoteNG.UI.Window
|
||||
public partial class ConnectionWindow : BaseWindow
|
||||
{
|
||||
public TabControl TabController;
|
||||
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
|
||||
|
||||
#region Public Methods
|
||||
public ConnectionWindow(DockContent panel, string formText = "")
|
||||
@@ -335,7 +336,7 @@ namespace mRemoteNG.UI.Window
|
||||
if (modelAsContainer != null)
|
||||
ConnectionInitiator.OpenConnection(modelAsContainer);
|
||||
else if (modelAsConnection != null)
|
||||
ConnectionInitiator.OpenConnection(modelAsConnection);
|
||||
_connectionInitiator.OpenConnection(modelAsConnection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,6 +187,7 @@
|
||||
<Compile Include="Connection\Converter.cs" />
|
||||
<Compile Include="Connection\DefaultConnectionInfo.cs" />
|
||||
<Compile Include="Connection\DefaultConnectionInheritance.cs" />
|
||||
<Compile Include="Connection\IConnectionInitiator.cs" />
|
||||
<Compile Include="Connection\IInheritable.cs" />
|
||||
<Compile Include="Connection\IHasParent.cs" />
|
||||
<Compile Include="Connection\Protocol\ProtocolFactory.cs" />
|
||||
|
||||
Reference in New Issue
Block a user