diff --git a/TGS.Interface/ServerInterface.cs b/TGS.Interface/ServerInterface.cs
index 5045a3e2f8..bdb1d295aa 100644
--- a/TGS.Interface/ServerInterface.cs
+++ b/TGS.Interface/ServerInterface.cs
@@ -9,6 +9,7 @@ using System.Security.Principal;
using System.ServiceModel;
using System.ServiceModel.Description;
using TGS.Interface.Components;
+using TGS.Interface.Wrappers;
namespace TGS.Interface
{
@@ -196,23 +197,24 @@ namespace TGS.Interface
///
public T GetComponent()
{
- var ToT = typeof(T);
- return GetComponentImpl(true);
+ if(InstanceName == null)
+ throw new InvalidOperationException("Instance not selected!");
+ return GetComponent(InstanceName);
}
///
/// 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 name of the to use
/// The correct component
- T GetComponentImpl(bool useInstanceName)
+ internal T GetComponent(string instanceName)
{
- if (useInstanceName & InstanceName == null)
- throw new Exception("Instance not selected!");
+ if (disposedValue)
+ throw new ObjectDisposedException(GetType().Name);
var actualToT = typeof(T);
var tot = actualToT.Name;
- if (actualToT == typeof(ITGConnectivity) && !useInstanceName)
+ if (actualToT == typeof(ITGConnectivity) && instanceName == null)
tot = 'S' + tot;
ChannelFactory cf;
@@ -231,7 +233,7 @@ namespace TGS.Interface
ChannelFactoryCache[tot].Abort();
ChannelFactoryCache.Remove(tot);
}
- cf = CreateChannel(useInstanceName ? InstanceName : null);
+ cf = CreateChannel(instanceName);
ChannelFactoryCache[tot] = cf;
}
return cf.CreateChannel();
@@ -241,7 +243,7 @@ namespace TGS.Interface
public T GetServiceComponent()
{
var ToT = typeof(T);
- return GetComponentImpl(false);
+ return GetComponent(null);
}
///
@@ -328,7 +330,7 @@ namespace TGS.Interface
{
try
{
- GetComponentImpl(false).VerifyConnection();
+ GetComponent(null).VerifyConnection();
}
catch (Exception e)
{
diff --git a/TGS.Interface/TGS.Interface.csproj b/TGS.Interface/TGS.Interface.csproj
index a4c2eae616..80043925e2 100644
--- a/TGS.Interface/TGS.Interface.csproj
+++ b/TGS.Interface/TGS.Interface.csproj
@@ -67,6 +67,7 @@
+
diff --git a/TGS.Interface/Wrappers/Instance.cs b/TGS.Interface/Wrappers/Instance.cs
new file mode 100644
index 0000000000..355c0d831d
--- /dev/null
+++ b/TGS.Interface/Wrappers/Instance.cs
@@ -0,0 +1,64 @@
+using TGS.Interface.Components;
+
+namespace TGS.Interface.Wrappers
+{
+ ///
+ sealed class Instance : IInstance
+ {
+ ///
+ /// The backing
+ ///
+ readonly ServerInterface serverInterface;
+ ///
+ /// The name of the
+ ///
+ readonly string instanceName;
+
+ ///
+ /// Construct an
+ ///
+ /// The to use
+ /// The name to use
+ public Instance(ServerInterface _serverInterface, string _instanceName)
+ {
+ serverInterface = _serverInterface;
+ instanceName = _instanceName;
+ }
+
+ ///
+ public ITGAdministration Administration => serverInterface.GetComponent(instanceName);
+
+ ///
+ public ITGByond Byond => serverInterface.GetComponent(instanceName);
+
+ ///
+ public ITGChat Chat => serverInterface.GetComponent(instanceName);
+
+ ///
+ public ITGCompiler Compiler => serverInterface.GetComponent(instanceName);
+
+ ///
+ public ITGConfig Config => serverInterface.GetComponent(instanceName);
+
+ ///
+ public ITGDreamDaemon DreamDaemon => serverInterface.GetComponent(instanceName);
+
+ ///
+ public ITGInterop Interop => serverInterface.GetComponent(instanceName);
+
+ ///
+ public ITGRepository Repository => serverInterface.GetComponent(instanceName);
+
+ ///
+ public string ServerDirectory()
+ {
+ return serverInterface.GetComponent(instanceName).ServerDirectory();
+ }
+
+ ///
+ public string Version()
+ {
+ return serverInterface.GetComponent(instanceName).Version();
+ }
+ }
+}