diff --git a/TGServiceInterface/Server.cs b/TGServiceInterface/Server.cs
index a0bf48284b..0a09c88ed1 100644
--- a/TGServiceInterface/Server.cs
+++ b/TGServiceInterface/Server.cs
@@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Linq;
using System.Net;
using System.Net.Security;
+using System.Reflection;
using System.Security.Principal;
using System.ServiceModel;
+
namespace TGServiceInterface
{
public class Server
@@ -12,7 +15,7 @@ namespace TGServiceInterface
///
/// List of types that can be used with GetComponen
///
- public static readonly IList ValidInterfaces = new List { typeof(ITGByond), typeof(ITGChat), typeof(ITGCompiler), typeof(ITGConfig), typeof(ITGDreamDaemon), typeof(ITGRepository), typeof(ITGSService), typeof(ITGConnectivity), typeof(ITGAdministration), typeof(ITGInterop) };
+ public static readonly IList ValidInterfaces = CollectComponents();
///
/// The maximum message size to and from a local server
@@ -51,6 +54,22 @@ namespace TGServiceInterface
static string HTTPSPassword;
static Dictionary ChannelFactoryCache = new Dictionary();
+
+ ///
+ /// Returns a of s that can be used with the service
+ ///
+ /// A of s that can be used with the service
+ static IList CollectComponents()
+ {
+ //find all interfaces in this assembly in this namespace that have the service contract attribute
+ var query = from t in Assembly.GetExecutingAssembly().GetTypes()
+ where t.IsInterface
+ && t.Namespace == typeof(Server).Namespace
+ && t.GetCustomAttribute(typeof(ServiceContractAttribute)) != null
+ select t;
+ return query.ToList();
+ }
+
public static void SetBadCertificateHandler(Func handler)
{
ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, error) =>
@@ -97,8 +116,8 @@ namespace TGServiceInterface
public static bool VersionMismatch(out string errorMessage)
{
- var splits = Server.GetComponent().Version().Split(' ');
- var theirs = new Version(splits[splits.Length - 1].Substring(1));
+ var splits = Server.GetComponent().Version().Split(' ');
+ var theirs = new Version(splits[splits.Length - 1].Substring(1));
var ours = new Version(FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion);
if(theirs != ours)
{