From 947477109895f0d5448f293cd8d5ddc24a479718 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 1 Mar 2020 16:30:51 -0600 Subject: [PATCH] ToolBox.cs - replace serious of ifs with LINQ filters --- BizHawk.Client.Common/tools/Watch/Watch.cs | 2 +- BizHawk.Client.EmuHawk/tools/ToolBox.cs | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/BizHawk.Client.Common/tools/Watch/Watch.cs b/BizHawk.Client.Common/tools/Watch/Watch.cs index 320dadd29a..617ce3aaa3 100644 --- a/BizHawk.Client.Common/tools/Watch/Watch.cs +++ b/BizHawk.Client.Common/tools/Watch/Watch.cs @@ -310,7 +310,7 @@ namespace BizHawk.Client.Common return _domain.PeekUshort(Address, BigEndian); } - return _domain.PeekUshort(Address % _domain.Size, BigEndian); // TODO: % size stil lisn't correct since it could be the last byte of the domain + return _domain.PeekUshort(Address % _domain.Size, BigEndian); // TODO: % size still isn't correct since it could be the last byte of the domain } protected uint GetDWord(bool bypassFreeze = false) diff --git a/BizHawk.Client.EmuHawk/tools/ToolBox.cs b/BizHawk.Client.EmuHawk/tools/ToolBox.cs index ddfecb0f3b..f36589a927 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolBox.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolBox.cs @@ -52,21 +52,15 @@ namespace BizHawk.Client.EmuHawk { ToolBoxStrip.Items.Clear(); - foreach (var t in Assembly.GetAssembly(GetType()).GetTypes()) - { - if (!typeof(IToolForm).IsAssignableFrom(t)) - continue; - if (!typeof(Form).IsAssignableFrom(t)) - continue; - if (typeof(ToolBox).IsAssignableFrom(t)) - continue; - if (VersionInfo.DeveloperBuild && t.GetCustomAttributes(false).OfType().Any(a => !a.Released)) - continue; - if (!ServiceInjector.IsAvailable(Emulator.ServiceProvider, t)) - continue; -// if (!ApiInjector.IsAvailable(, t)) -// continue; + var tools = Assembly.GetAssembly(GetType()).GetTypes() + .Where(t => typeof(IToolForm).IsAssignableFrom(t)) + .Where(t => typeof(Form).IsAssignableFrom(t)) + .Where(t => !typeof(ToolBox).IsAssignableFrom(t)) + .Where(t => ServiceInjector.IsAvailable(Emulator.ServiceProvider, t)) + .Where(t => VersionInfo.DeveloperBuild || t.GetCustomAttributes(false).OfType().Any(a => a.Released)); + foreach (var t in tools) + { var instance = Activator.CreateInstance(t); var tsb = new ToolStripButton