Replace remaining LINQ DSL with method chains
This commit is contained in:
parent
90623d36e2
commit
f45201ce7a
|
@ -417,9 +417,7 @@ namespace BizHawk.Client.ApiHawk
|
||||||
{
|
{
|
||||||
AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter;
|
AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter;
|
||||||
|
|
||||||
IEnumerable<string> pressedButtons = from button in joypadAdaptor.Definition.BoolButtons
|
var pressedButtons = joypadAdaptor.Definition.BoolButtons.Where(joypadAdaptor.IsPressed);
|
||||||
where joypadAdaptor.IsPressed(button)
|
|
||||||
select button;
|
|
||||||
|
|
||||||
foreach (Joypad j in allJoypads)
|
foreach (Joypad j in allJoypads)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,10 +58,11 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
// Looks for bindings which are activated by the supplied physical button.
|
// Looks for bindings which are activated by the supplied physical button.
|
||||||
public List<string> SearchBindings(string button)
|
public List<string> SearchBindings(string button) =>
|
||||||
{
|
_bindings.SelectMany(kvp => kvp.Value, (kvp, boundButton) => new { kvp.Key, boundButton })
|
||||||
return (from kvp in _bindings from boundButton in kvp.Value where boundButton == button select kvp.Key).ToList();
|
.Where(pair => pair.boundButton == button)
|
||||||
}
|
.Select(pair => pair.Key)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
// Searches bindings for the controller and returns true if this binding is mapped somewhere in this controller
|
// Searches bindings for the controller and returns true if this binding is mapped somewhere in this controller
|
||||||
public bool HasBinding(string button)
|
public bool HasBinding(string button)
|
||||||
|
@ -227,12 +228,14 @@ namespace BizHawk.Client.Common
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of all keys mapped and the name of the button they are mapped to
|
/// Returns a list of all keys mapped and the name of the button they are mapped to
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<KeyValuePair<string, string>> MappingList()
|
public List<KeyValuePair<string, string>> MappingList() => _bindings.SelectMany(
|
||||||
{
|
key => key.Value,
|
||||||
return (from key in _bindings from binding in key.Value select new KeyValuePair<string, string>(binding, key.Key)).ToList();
|
(key, binding) => new KeyValuePair<string, string>(binding, key.Key))
|
||||||
}
|
.ToList();
|
||||||
|
|
||||||
public List<string> PressedButtons => (from button in _buttons where button.Value select button.Key).ToList();
|
public List<string> PressedButtons => _buttons.Where(button => button.Value)
|
||||||
|
.Select(button => button.Key)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AutofireController : IController
|
public class AutofireController : IController
|
||||||
|
@ -282,10 +285,11 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for bindings which are activated by the supplied physical button.
|
// look for bindings which are activated by the supplied physical button.
|
||||||
public List<string> SearchBindings(string button)
|
public List<string> SearchBindings(string button) =>
|
||||||
{
|
_bindings.SelectMany(kvp => kvp.Value, (kvp, bound_button) => new { kvp, bound_button })
|
||||||
return (from kvp in _bindings from bound_button in kvp.Value where bound_button == button select kvp.Key).ToList();
|
.Where(o => o.bound_button == button)
|
||||||
}
|
.Select(o => o.kvp.Key)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// uses the bindings to latch our own logical button state from the source controller's button state (which are assumed to be the physical side of the binding).
|
/// uses the bindings to latch our own logical button state from the source controller's button state (which are assumed to be the physical side of the binding).
|
||||||
|
@ -355,6 +359,8 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> PressedButtons => (from button in _buttons where button.Value select button.Key).ToList();
|
public List<string> PressedButtons => _buttons.Where(button => button.Value)
|
||||||
|
.Select(button => button.Key)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -203,10 +203,7 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
// get all options for this firmware (in order)
|
// get all options for this firmware (in order)
|
||||||
var fr1 = fr;
|
var fr1 = fr;
|
||||||
var options =
|
var options = FirmwareDatabase.FirmwareOptions.Where(fo => fo.SystemId == fr1.SystemId && fo.FirmwareId == fr1.FirmwareId && fo.IsAcceptableOrIdeal);
|
||||||
from fo in FirmwareDatabase.FirmwareOptions
|
|
||||||
where fo.SystemId == fr1.SystemId && fo.FirmwareId == fr1.FirmwareId && fo.IsAcceptableOrIdeal
|
|
||||||
select fo;
|
|
||||||
|
|
||||||
// try each option
|
// try each option
|
||||||
foreach (var fo in options)
|
foreach (var fo in options)
|
||||||
|
@ -273,12 +270,7 @@ namespace BizHawk.Client.Common
|
||||||
ri.KnownFirmwareFile = ff;
|
ri.KnownFirmwareFile = ff;
|
||||||
|
|
||||||
// if the known firmware file is for a different firmware, flag it so we can show a warning
|
// if the known firmware file is for a different firmware, flag it so we can show a warning
|
||||||
var option =
|
if (FirmwareDatabase.FirmwareOptions.Any(fo => fo.Hash == rff.Hash && fo.ConfigKey != fr.ConfigKey))
|
||||||
(from fo in FirmwareDatabase.FirmwareOptions
|
|
||||||
where fo.Hash == rff.Hash && fo.ConfigKey != fr.ConfigKey
|
|
||||||
select fr).FirstOrDefault();
|
|
||||||
|
|
||||||
if (option != null)
|
|
||||||
{
|
{
|
||||||
ri.KnownMismatching = true;
|
ri.KnownMismatching = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,13 +96,8 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Binding> entriesToRemove = (from entry in Bindings let binding = DefaultValues.FirstOrDefault(b => b.DisplayName == entry.DisplayName) where binding == null select entry).ToList();
|
|
||||||
|
|
||||||
// Remove entries that no longer exist in defaults
|
// Remove entries that no longer exist in defaults
|
||||||
foreach (Binding entry in entriesToRemove)
|
Bindings.RemoveAll(entry => DefaultValues.All(b => b.DisplayName != entry.DisplayName));
|
||||||
{
|
|
||||||
Bindings.Remove(entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Binding> _defaultValues;
|
private static List<Binding> _defaultValues;
|
||||||
|
|
|
@ -119,11 +119,7 @@ namespace BizHawk.Client.Common
|
||||||
private static IEnumerable<Type> ImportersForExtension(string ext)
|
private static IEnumerable<Type> ImportersForExtension(string ext)
|
||||||
{
|
{
|
||||||
var info = typeof(MovieImport).Module;
|
var info = typeof(MovieImport).Module;
|
||||||
var importers = from t in info.GetTypes()
|
var importers = info.GetTypes().Where(t => typeof(IMovieImport).IsAssignableFrom(t) && TypeImportsExtension(t, ext));
|
||||||
where typeof(IMovieImport).IsAssignableFrom(t)
|
|
||||||
&& TypeImportsExtension(t, ext)
|
|
||||||
select t;
|
|
||||||
|
|
||||||
return importers;
|
return importers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -483,10 +483,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var fr = (FirmwareDatabase.FirmwareRecord)lvi.Tag;
|
var fr = (FirmwareDatabase.FirmwareRecord)lvi.Tag;
|
||||||
|
|
||||||
// get all options for this firmware (in order)
|
// get all options for this firmware (in order)
|
||||||
var options =
|
var options = FirmwareDatabase.FirmwareOptions.Where(fo => fo.SystemId == fr.SystemId && fo.FirmwareId == fr.FirmwareId);
|
||||||
from fo in FirmwareDatabase.FirmwareOptions
|
|
||||||
where fo.SystemId == fr.SystemId && fo.FirmwareId == fr.FirmwareId
|
|
||||||
select fo;
|
|
||||||
|
|
||||||
FirmwaresConfigInfo fciDialog = new FirmwaresConfigInfo
|
FirmwaresConfigInfo fciDialog = new FirmwaresConfigInfo
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,8 +111,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
var lti = output as LuaTable;
|
var lti = output as LuaTable;
|
||||||
|
|
||||||
var keys = (from object key in lti.Keys select key.ToString()).ToList();
|
var keys = lti.Keys.Cast<object>().Select(key => key.ToString()).ToList();
|
||||||
var values = (from object value in lti.Values select value.ToString()).ToList();
|
var values = lti.Values.Cast<object>().Select(value => value.ToString()).ToList();
|
||||||
|
|
||||||
var kvps = new List<KeyValuePair<string, string>>();
|
var kvps = new List<KeyValuePair<string, string>>();
|
||||||
for (var i = 0; i < keys.Count; i++)
|
for (var i = 0; i < keys.Count; i++)
|
||||||
|
|
|
@ -183,9 +183,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
return fileNodes;
|
return fileNodes;
|
||||||
|
|
||||||
// get all folders
|
// get all folders
|
||||||
List<KeyValuePair<string, ISONode>> dirs = (from a in Root.Children
|
var dirs = Root.Children.Where(a => a.Value is ISODirectoryNode).ToList();
|
||||||
where a.Value.GetType() == typeof(ISODirectoryNode)
|
|
||||||
select a).ToList();
|
|
||||||
// iterate through each folder
|
// iterate through each folder
|
||||||
foreach (var d in dirs)
|
foreach (var d in dirs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -755,8 +755,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
blobstrings.Add(t);
|
blobstrings.Add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
var tBlobs = (from a in tr.ImageFileNamePaths
|
var tBlobs = tr.ImageFileNamePaths.ToList();
|
||||||
select a).ToList();
|
|
||||||
|
|
||||||
if (tBlobs.Count < 1)
|
if (tBlobs.Count < 1)
|
||||||
throw new MDSParseException("BLOB Error!");
|
throw new MDSParseException("BLOB Error!");
|
||||||
|
|
Loading…
Reference in New Issue