From 400e4f4800a3b57ab647421e477c4c73ac6df34b Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 27 Oct 2015 19:03:56 -0400 Subject: [PATCH] Add an empty ICodeDataLogger emulator service, make it a required service for CDL.cs --- BizHawk.Client.EmuHawk/tools/CDL.cs | 3 +++ .../BizHawk.Emulation.Common.csproj | 1 + BizHawk.Emulation.Common/Extensions.cs | 15 +++++++++++++++ .../Interfaces/ICodeDataLogger.cs | 6 ++++++ 4 files changed, 25 insertions(+) create mode 100644 BizHawk.Emulation.Common/Interfaces/ICodeDataLogger.cs diff --git a/BizHawk.Client.EmuHawk/tools/CDL.cs b/BizHawk.Client.EmuHawk/tools/CDL.cs index 08d798cb8f..d17e9420af 100644 --- a/BizHawk.Client.EmuHawk/tools/CDL.cs +++ b/BizHawk.Client.EmuHawk/tools/CDL.cs @@ -44,6 +44,9 @@ namespace BizHawk.Client.EmuHawk [RequiredService] private IMemoryDomains MemoryDomains { get; set; } + [RequiredService] + private ICodeDataLogger CodeDataLogger { get; set; } + private string _currentFileName = string.Empty; public CDL() diff --git a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj index dd74e4459f..ba070905d0 100644 --- a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj +++ b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj @@ -73,6 +73,7 @@ + diff --git a/BizHawk.Emulation.Common/Extensions.cs b/BizHawk.Emulation.Common/Extensions.cs index c1130930f0..a4697d036a 100644 --- a/BizHawk.Emulation.Common/Extensions.cs +++ b/BizHawk.Emulation.Common/Extensions.cs @@ -240,6 +240,21 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions return (IRegionable)core.ServiceProvider.GetService(); } + public static bool CanDataLog(this IEmulator core) + { + if (core == null) + { + return false; + } + + return core.ServiceProvider.HasService(); + } + + public static ICodeDataLogger AsCodeDataLogger(this IEmulator core) + { + return core.ServiceProvider.GetService(); + } + // TODO: a better place for these public static bool IsImplemented(this MethodInfo info) { diff --git a/BizHawk.Emulation.Common/Interfaces/ICodeDataLogger.cs b/BizHawk.Emulation.Common/Interfaces/ICodeDataLogger.cs new file mode 100644 index 0000000000..dcdd063137 --- /dev/null +++ b/BizHawk.Emulation.Common/Interfaces/ICodeDataLogger.cs @@ -0,0 +1,6 @@ +namespace BizHawk.Emulation.Common +{ + public interface ICodeDataLogger : IEmulatorService + { + } +}