Cleanup LINQ in VirtualpadTool.CreatePads

This commit is contained in:
YoshiRulz 2020-12-22 18:28:41 +10:00
parent 9124b0f3b5
commit 790a09067e
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 12 additions and 10 deletions

View File

@ -74,16 +74,18 @@ namespace BizHawk.Client.EmuHawk
{
ControllerPanel.Controls.Clear();
var schemaType = EmuHawk.ReflectionCache.Types
.Where(t => typeof(IVirtualPadSchema)
.IsAssignableFrom(t) && t.GetCustomAttributes(false)
.OfType<SchemaAttribute>()
.Any())
.FirstOrDefault(t => t.GetCustomAttributes(false)
.OfType<SchemaAttribute>()
.First().SystemId == Emulator.SystemId);
if (schemaType == null) return;
Type schemaType;
try
{
schemaType = EmuHawk.ReflectionCache.Types.Where(typeof(IVirtualPadSchema).IsAssignableFrom)
.Select(t => (SchemaType: t, Attr: t.GetCustomAttributes(false).OfType<SchemaAttribute>().FirstOrDefault()))
.First(tuple => tuple.Attr?.SystemId == Emulator.SystemId)
.SchemaType;
}
catch (Exception)
{
return;
}
var padSchemata = ((IVirtualPadSchema) Activator.CreateInstance(schemaType))
.GetPadSchemas(Emulator, s => MessageBox.Show(s))