ToolBox.cs - replace serious of ifs with LINQ filters

This commit is contained in:
adelikat 2020-03-01 16:30:51 -06:00
parent ff836b7089
commit 9474771098
2 changed files with 9 additions and 15 deletions

View File

@ -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)

View File

@ -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<ToolAttribute>().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<ToolAttribute>().Any(a => a.Released));
foreach (var t in tools)
{
var instance = Activator.CreateInstance(t);
var tsb = new ToolStripButton