diff --git a/TGCommandLine/ConsoleCommand.cs b/TGCommandLine/ConsoleCommand.cs
index 8584017716..7f9489d1c1 100644
--- a/TGCommandLine/ConsoleCommand.cs
+++ b/TGCommandLine/ConsoleCommand.cs
@@ -5,8 +5,8 @@ namespace TGCommandLine
abstract class ConsoleCommand : Command
{
///
- /// The currently in use by the
+ /// The currently in use by the
///
- public static Interface Interface;
+ public static IInterface Interface;
}
}
diff --git a/TGCommandLine/InstanceRootCommand.cs b/TGCommandLine/InstanceRootCommand.cs
index 34685e8395..85fd78610b 100644
--- a/TGCommandLine/InstanceRootCommand.cs
+++ b/TGCommandLine/InstanceRootCommand.cs
@@ -5,7 +5,7 @@ namespace TGCommandLine
{
abstract class InstanceRootCommand : RootCommand
{
- public static Interface currentInterface;
+ public static IInterface currentInterface;
public override ExitCode DoRun(IList parameters)
{
if (currentInterface.InstanceName == null)
diff --git a/TGCommandLine/Program.cs b/TGCommandLine/Program.cs
index 1772582cc5..738434571d 100644
--- a/TGCommandLine/Program.cs
+++ b/TGCommandLine/Program.cs
@@ -10,7 +10,7 @@ namespace TGCommandLine
class Program
{
static bool interactive = false, saidSrvVersion = false;
- static Interface currentInterface;
+ static IInterface currentInterface;
static Command.ExitCode RunCommandLine(IList argsAsList)
{
//first lookup the connection string
@@ -100,7 +100,7 @@ namespace TGCommandLine
};
}
- static void ReplaceInterface(Interface I)
+ static void ReplaceInterface(IInterface I)
{
currentInterface = I;
ConsoleCommand.Interface = I;
@@ -157,7 +157,7 @@ namespace TGCommandLine
///
/// The name of the to test
/// If , does not output on success
- /// if a was achieved with , otherwise
+ /// if a was achieved with , otherwise
static bool CheckInstanceConnectivity(string instanceName, bool silentSuccess)
{
var res = currentInterface.ConnectToInstance(instanceName);
diff --git a/TGCommandLine/RootCommands.cs b/TGCommandLine/RootCommands.cs
index 4e6e3d4b69..6394224cd7 100644
--- a/TGCommandLine/RootCommands.cs
+++ b/TGCommandLine/RootCommands.cs
@@ -7,7 +7,7 @@ namespace TGCommandLine
{
class CLICommand : RootCommand
{
- public CLICommand(Interface I)
+ public CLICommand(IInterface I)
{
var tmp = new List { new UpdateCommand(), new TestmergeCommand(), new RepoCommand(), new BYONDCommand(), new DMCommand(), new DDCommand(), new ConfigCommand(), new IRCCommand(), new DiscordCommand(), new AutoUpdateCommand(), new SetAutoUpdateCommand() };
if (I.ConnectToInstance().HasFlag(ConnectivityLevel.Administrator))
diff --git a/TGControlPanel/ControlPanel/ControlPanel.cs b/TGControlPanel/ControlPanel/ControlPanel.cs
index d047906de6..7a7ead308e 100644
--- a/TGControlPanel/ControlPanel/ControlPanel.cs
+++ b/TGControlPanel/ControlPanel/ControlPanel.cs
@@ -18,15 +18,15 @@ namespace TGControlPanel
public static IDictionary InstancesInUse { get; private set; } = new Dictionary();
///
- /// The instance for this
+ /// The instance for this
///
- readonly Interface Interface;
+ readonly IInterface Interface;
///
/// Constructs a
///
- /// The for the
- public ControlPanel(Interface I)
+ /// The for the
+ public ControlPanel(IInterface I)
{
InitializeComponent();
Interface = I;
diff --git a/TGControlPanel/InstanceSelector.cs b/TGControlPanel/InstanceSelector.cs
index fa6ae73761..607227b771 100644
--- a/TGControlPanel/InstanceSelector.cs
+++ b/TGControlPanel/InstanceSelector.cs
@@ -12,14 +12,14 @@ namespace TGControlPanel
partial class InstanceSelector : CountedForm
{
///
- /// The we build instance connections from
+ /// The we build instance connections from
///
- readonly Interface masterInterface;
+ readonly IInterface masterInterface;
///
/// List of from
///
IList InstanceData;
- public InstanceSelector(Interface I)
+ public InstanceSelector(IInterface I)
{
InitializeComponent();
InstanceListBox.MouseDoubleClick += InstanceListBox_MouseDoubleClick;
@@ -100,7 +100,7 @@ namespace TGControlPanel
activeCP.BringToFront();
return;
}
- var InstanceAccessor = new Interface(masterInterface);
+ var InstanceAccessor = new Interface(masterInterface as Interface);
try
{
ConnectivityLevel res = ConnectivityLevel.None;
diff --git a/TGControlPanel/Login.cs b/TGControlPanel/Login.cs
index 4174c9d85f..75b1a508b3 100644
--- a/TGControlPanel/Login.cs
+++ b/TGControlPanel/Login.cs
@@ -58,7 +58,7 @@ namespace TGControlPanel
VerifyAndConnect(new Interface());
}
- void VerifyAndConnect(Interface I)
+ void VerifyAndConnect(IInterface I)
{
try
{
diff --git a/TGInstallerWrapper/Main.cs b/TGInstallerWrapper/Main.cs
index ab339ad63e..fb91b05329 100644
--- a/TGInstallerWrapper/Main.cs
+++ b/TGInstallerWrapper/Main.cs
@@ -20,7 +20,7 @@ namespace TGInstallerWrapper
bool cancelled = false;
bool pathIsDefault = true;
- Interface Interface;
+ IInterface Interface;
///
/// Construct an installer form
diff --git a/TGServerService/ServerInstance/DreamDaemon.cs b/TGServerService/ServerInstance/DreamDaemon.cs
index 51c7acecb2..02e91cc34d 100644
--- a/TGServerService/ServerInstance/DreamDaemon.cs
+++ b/TGServerService/ServerInstance/DreamDaemon.cs
@@ -530,7 +530,7 @@ namespace TGServerService
return;
//Copy the interface dll to the static dir
- var InterfacePath = Assembly.GetAssembly(typeof(Interface)).Location;
+ var InterfacePath = Assembly.GetAssembly(typeof(IInterface)).Location;
//bridge is installed next to the interface
var BridgePath = Path.Combine(Path.GetDirectoryName(InterfacePath), BridgeDLLName);
#if DEBUG
diff --git a/TGServiceInterface/Interface.cs b/TGServiceInterface/Interface.cs
index 57488c1467..bc099949b9 100644
--- a/TGServiceInterface/Interface.cs
+++ b/TGServiceInterface/Interface.cs
@@ -12,9 +12,74 @@ using TGServiceInterface.Components;
namespace TGServiceInterface
{
///
- /// Main inteface class for the service
+ /// Main inteface for communicating the
///
- sealed public class Interface : IDisposable
+ public interface IInterface : IDisposable
+ {
+ ///
+ /// The name of the current instance in use. Defaults to
+ ///
+ string InstanceName { get; }
+
+ ///
+ /// If this is set, we will try and connect to an HTTPS server running at this address
+ ///
+ string HTTPSURL { get; }
+
+ ///
+ /// The port used to connect to the
+ ///
+ ushort HTTPSPort { get; }
+
+ ///
+ /// Checks if the is setup for a remote connection
+ ///
+ bool IsRemoteConnection { get; }
+
+ ///
+ /// Targets as the instance to use with . Closes all connections to any previous instance
+ ///
+ /// The name of the instance to connect to
+ /// If set to , skips the connectivity and authentication checks, sets , and returns
+ /// The apporopriate
+ ConnectivityLevel ConnectToInstance(string instanceName = null, bool skipChecks = false);
+
+ ///
+ /// Returns if the interface being used to connect to a service does not have the same release version as the service
+ ///
+ /// An error message to display to the user should this function return
+ /// if the interface being used to connect to a service does not have the same release version as the service
+ bool VersionMismatch(out string errorMessage);
+
+ ///
+ /// Returns the requested component for the instance . This does not guarantee a successful connection. s created this way are recycled for minimum latency and bandwidth usage
+ ///
+ /// The component to retrieve
+ /// The correct component
+ T GetComponent();
+
+ ///
+ /// Returns the component for the service
+ ///
+ /// The component for the service
+ ITGSService GetService();
+
+ ///
+ /// Used to test if the is avaiable on the target machine. Note that state can change at any time and any call into the may throw an exception because of communcation errors
+ ///
+ /// on successful connection, error message on failure
+ ConnectivityLevel ConnectionStatus();
+
+ ///
+ /// Used to test if the is avaiable on the target machine. Note that state can change at any time and any call into the may throw an exception because of communcation errors
+ ///
+ /// String of the error that prevented an elevated connectivity level
+ /// The apporopriate
+ ConnectivityLevel ConnectionStatus(out string error);
+ }
+
+ ///
+ sealed public class Interface : IInterface
{
///
/// List of s that can be used with and
@@ -40,21 +105,24 @@ namespace TGServiceInterface
///
public const string InstanceInterfaceName = MasterInterfaceName + "/Instance";
-
- ///
- /// The name of the current instance in use. Defaults to
- ///
+ ///
public string InstanceName { get; private set; }
///
/// If this is set, we will try and connect to an HTTPS server running at this address
///
- public readonly string HTTPSURL;
+ readonly string _HTTPSURL;
+
+ ///
+ public string HTTPSURL { get { return _HTTPSURL; } }
///
- /// The port used by the service
+ /// The port used to connect to the
///
- public readonly ushort HTTPSPort;
+ readonly ushort _HTTPSPort;
+
+ ///
+ public ushort HTTPSPort { get { return _HTTPSPort; } }
///
/// Username for remote operations
@@ -133,8 +201,8 @@ namespace TGServiceInterface
/// Windows account password for the remote server
public Interface(string address, ushort port, string username, string password)
{
- HTTPSURL = address;
- HTTPSPort = port;
+ _HTTPSURL = address;
+ _HTTPSPort = port;
HTTPSUsername = username;
HTTPSPassword = password;
}
@@ -142,15 +210,10 @@ namespace TGServiceInterface
///
/// Constructs an that connects to the same as some
///
- ///
+ /// Another to copy settings from
public Interface(Interface other) : this(other.HTTPSURL, other.HTTPSPort, other.HTTPSUsername, other.HTTPSPassword) { }
- ///
- /// Targets as the instance to use with . Closes all connections to any previous instance
- ///
- /// The name of the instance to connect to
- /// If set to , skips the connectivity and authentication checks, sets , and returns
- /// The apporopriate
+ ///
public ConnectivityLevel ConnectToInstance(string instanceName = null, bool skipChecks = false)
{
if (instanceName == null)
@@ -191,9 +254,7 @@ namespace TGServiceInterface
}
}
- ///
- /// Checks if the is setup for a remote connection
- ///
+ ///
public bool IsRemoteConnection { get { return HTTPSURL != null; } }
///
@@ -224,11 +285,7 @@ namespace TGServiceInterface
}
}
- ///
- /// Returns if the interface being used to connect to a service does not have the same release version as the service
- ///
- /// An error message to display to the user should this function return
- /// if the interface being used to connect to a service does not have the same release version as the service
+ ///
public bool VersionMismatch(out string errorMessage)
{
var splits = GetService().Version().Split(' ');
@@ -253,11 +310,7 @@ namespace TGServiceInterface
(sender as IDisposable).Dispose();
}
- ///
- /// Returns the requested component for the instance . This does not guarantee a successful connection. s created this way are recycled for minimum latency and bandwidth usage
- ///
- /// The component to retrieve
- /// The correct component
+ ///
public T GetComponent()
{
var ToT = typeof(T);
@@ -265,7 +318,13 @@ namespace TGServiceInterface
throw new Exception("Invalid type!");
return GetComponentImpl(true);
}
-
+
+ ///
+ /// Returns the requested component for the instance . This does not guarantee a successful connection. s created this way are recycled for minimum latency and bandwidth usage
+ ///
+ /// The component to retrieve
+ /// If should be used to connect
+ /// The correct component
T GetComponentImpl(bool useInstanceName)
{
if (useInstanceName & InstanceName == null)
@@ -297,10 +356,7 @@ namespace TGServiceInterface
return cf.CreateChannel();
}
- ///
- /// Returns the component for the service
- ///
- /// The component for the service
+ ///
public ITGSService GetService()
{
return GetComponentImpl(false);
@@ -346,20 +402,13 @@ namespace TGServiceInterface
return res;
}
- ///
- /// Used to test if the is avaiable on the target machine. Note that state can change at any time and any call into the may throw an exception because of communcation errors
- ///
- /// on successful connection, error message on failure
+ ///
public ConnectivityLevel ConnectionStatus()
{
return ConnectionStatus(out string unused);
}
- ///
- /// Used to test if the is avaiable on the target machine. Note that state can change at any time and any call into the may throw an exception because of communcation errors
- ///
- /// String of the error that prevented an elevated connectivity level
- /// The apporopriate
+ ///
public ConnectivityLevel ConnectionStatus(out string error)
{
try