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;
|
||||
|
||||
IEnumerable<string> pressedButtons = from button in joypadAdaptor.Definition.BoolButtons
|
||||
where joypadAdaptor.IsPressed(button)
|
||||
select button;
|
||||
var pressedButtons = joypadAdaptor.Definition.BoolButtons.Where(joypadAdaptor.IsPressed);
|
||||
|
||||
foreach (Joypad j in allJoypads)
|
||||
{
|
||||
|
|
|
@ -58,10 +58,11 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
// Looks for bindings which are activated by the supplied physical button.
|
||||
public List<string> SearchBindings(string button)
|
||||
{
|
||||
return (from kvp in _bindings from boundButton in kvp.Value where boundButton == button select kvp.Key).ToList();
|
||||
}
|
||||
public List<string> SearchBindings(string button) =>
|
||||
_bindings.SelectMany(kvp => kvp.Value, (kvp, boundButton) => new { kvp.Key, boundButton })
|
||||
.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
|
||||
public bool HasBinding(string button)
|
||||
|
@ -227,12 +228,14 @@ namespace BizHawk.Client.Common
|
|||
/// <summary>
|
||||
/// Returns a list of all keys mapped and the name of the button they are mapped to
|
||||
/// </summary>
|
||||
public List<KeyValuePair<string, string>> MappingList()
|
||||
{
|
||||
return (from key in _bindings from binding in key.Value select new KeyValuePair<string, string>(binding, key.Key)).ToList();
|
||||
}
|
||||
public List<KeyValuePair<string, string>> MappingList() => _bindings.SelectMany(
|
||||
key => key.Value,
|
||||
(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
|
||||
|
@ -282,10 +285,11 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
// look for bindings which are activated by the supplied physical button.
|
||||
public List<string> SearchBindings(string button)
|
||||
{
|
||||
return (from kvp in _bindings from bound_button in kvp.Value where bound_button == button select kvp.Key).ToList();
|
||||
}
|
||||
public List<string> SearchBindings(string button) =>
|
||||
_bindings.SelectMany(kvp => kvp.Value, (kvp, bound_button) => new { kvp, bound_button })
|
||||
.Where(o => o.bound_button == button)
|
||||
.Select(o => o.kvp.Key)
|
||||
.ToList();
|
||||
|
||||
/// <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).
|
||||
|
@ -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)
|
||||
var fr1 = fr;
|
||||
var options =
|
||||
from fo in FirmwareDatabase.FirmwareOptions
|
||||
where fo.SystemId == fr1.SystemId && fo.FirmwareId == fr1.FirmwareId && fo.IsAcceptableOrIdeal
|
||||
select fo;
|
||||
var options = FirmwareDatabase.FirmwareOptions.Where(fo => fo.SystemId == fr1.SystemId && fo.FirmwareId == fr1.FirmwareId && fo.IsAcceptableOrIdeal);
|
||||
|
||||
// try each option
|
||||
foreach (var fo in options)
|
||||
|
@ -273,12 +270,7 @@ namespace BizHawk.Client.Common
|
|||
ri.KnownFirmwareFile = ff;
|
||||
|
||||
// if the known firmware file is for a different firmware, flag it so we can show a warning
|
||||
var option =
|
||||
(from fo in FirmwareDatabase.FirmwareOptions
|
||||
where fo.Hash == rff.Hash && fo.ConfigKey != fr.ConfigKey
|
||||
select fr).FirstOrDefault();
|
||||
|
||||
if (option != null)
|
||||
if (FirmwareDatabase.FirmwareOptions.Any(fo => fo.Hash == rff.Hash && fo.ConfigKey != fr.ConfigKey))
|
||||
{
|
||||
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
|
||||
foreach (Binding entry in entriesToRemove)
|
||||
{
|
||||
Bindings.Remove(entry);
|
||||
}
|
||||
Bindings.RemoveAll(entry => DefaultValues.All(b => b.DisplayName != entry.DisplayName));
|
||||
}
|
||||
|
||||
private static List<Binding> _defaultValues;
|
||||
|
|
|
@ -119,11 +119,7 @@ namespace BizHawk.Client.Common
|
|||
private static IEnumerable<Type> ImportersForExtension(string ext)
|
||||
{
|
||||
var info = typeof(MovieImport).Module;
|
||||
var importers = from t in info.GetTypes()
|
||||
where typeof(IMovieImport).IsAssignableFrom(t)
|
||||
&& TypeImportsExtension(t, ext)
|
||||
select t;
|
||||
|
||||
var importers = info.GetTypes().Where(t => typeof(IMovieImport).IsAssignableFrom(t) && TypeImportsExtension(t, ext));
|
||||
return importers;
|
||||
}
|
||||
|
||||
|
|
|
@ -483,10 +483,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var fr = (FirmwareDatabase.FirmwareRecord)lvi.Tag;
|
||||
|
||||
// get all options for this firmware (in order)
|
||||
var options =
|
||||
from fo in FirmwareDatabase.FirmwareOptions
|
||||
where fo.SystemId == fr.SystemId && fo.FirmwareId == fr.FirmwareId
|
||||
select fo;
|
||||
var options = FirmwareDatabase.FirmwareOptions.Where(fo => fo.SystemId == fr.SystemId && fo.FirmwareId == fr.FirmwareId);
|
||||
|
||||
FirmwaresConfigInfo fciDialog = new FirmwaresConfigInfo
|
||||
{
|
||||
|
|
|
@ -111,8 +111,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
var sb = new StringBuilder();
|
||||
var lti = output as LuaTable;
|
||||
|
||||
var keys = (from object key in lti.Keys select key.ToString()).ToList();
|
||||
var values = (from object value in lti.Values select value.ToString()).ToList();
|
||||
var keys = lti.Keys.Cast<object>().Select(key => key.ToString()).ToList();
|
||||
var values = lti.Values.Cast<object>().Select(value => value.ToString()).ToList();
|
||||
|
||||
var kvps = new List<KeyValuePair<string, string>>();
|
||||
for (var i = 0; i < keys.Count; i++)
|
||||
|
|
|
@ -183,9 +183,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
return fileNodes;
|
||||
|
||||
// get all folders
|
||||
List<KeyValuePair<string, ISONode>> dirs = (from a in Root.Children
|
||||
where a.Value.GetType() == typeof(ISODirectoryNode)
|
||||
select a).ToList();
|
||||
var dirs = Root.Children.Where(a => a.Value is ISODirectoryNode).ToList();
|
||||
// iterate through each folder
|
||||
foreach (var d in dirs)
|
||||
{
|
||||
|
|
|
@ -755,8 +755,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
blobstrings.Add(t);
|
||||
}
|
||||
|
||||
var tBlobs = (from a in tr.ImageFileNamePaths
|
||||
select a).ToList();
|
||||
var tBlobs = tr.ImageFileNamePaths.ToList();
|
||||
|
||||
if (tBlobs.Count < 1)
|
||||
throw new MDSParseException("BLOB Error!");
|
||||
|
|
Loading…
Reference in New Issue