From 5c768b1dc4e58bdd50ab0678e7b2f0f004c56f0b Mon Sep 17 00:00:00 2001
From: adelikat <adelikat@tasvideos.org>
Date: Wed, 14 Jan 2015 22:53:08 +0000
Subject: [PATCH] IEmulatorServiceProvider - add an AvailableServices property,
 Service Provider - don't register type object

---
 .../Base Implementations/BasicServiceProvider.cs    | 13 +++++++++++++
 .../Interfaces/IEmulatorServiceProvider.cs          |  6 ++++++
 2 files changed, 19 insertions(+)

diff --git a/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs b/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs
index e34b506288..4a6912fb76 100644
--- a/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs	
+++ b/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs	
@@ -31,6 +31,11 @@ namespace BizHawk.Emulation.Common
 			{
 				Services.Add(coreType, core);
 				coreType = coreType.BaseType;
+
+				if (coreType == typeof(object)) // Don't register object
+				{
+					coreType = null;
+				}
 			}
 		}
 
@@ -69,5 +74,13 @@ namespace BizHawk.Emulation.Common
 		{
 			return Services.ContainsKey(t);
 		}
+
+		public IEnumerable<Type> AvailableServices
+		{
+			get
+			{
+				return Services.Select(d => d.Key);
+			}
+		}
 	}
 }
diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulatorServiceProvider.cs b/BizHawk.Emulation.Common/Interfaces/IEmulatorServiceProvider.cs
index e948045dca..14b48d1d6d 100644
--- a/BizHawk.Emulation.Common/Interfaces/IEmulatorServiceProvider.cs
+++ b/BizHawk.Emulation.Common/Interfaces/IEmulatorServiceProvider.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Collections.Generic;
 
 namespace BizHawk.Emulation.Common
 {
@@ -25,5 +26,10 @@ namespace BizHawk.Emulation.Common
 		/// Else returns null
 		/// </summary>
 		object GetService(Type t);
+
+		/// <summary>
+		/// A list of all cuurently registered services available to be called
+		/// </summary>
+		IEnumerable<Type> AvailableServices { get; }
 	}
 }