Get rid of more ElementAt usage

Old code is commented out as a reference
This commit is contained in:
Travis Nickles 2019-02-16 02:41:13 -06:00
parent 61a5ab07ea
commit 3417c08a87
2 changed files with 8 additions and 4 deletions

View File

@ -248,9 +248,11 @@ namespace DS4Windows
if (disabledDevCount > 0)
{
List<HidDevice> disabledDevList = new List<HidDevice>();
for (int i = 0, arlen = disabledDevCount; i < arlen; i++)
for (var devEnum = DisabledDevices.GetEnumerator(); devEnum.MoveNext();)
//for (int i = 0, arlen = disabledDevCount; i < arlen; i++)
{
HidDevice tempDev = DisabledDevices.ElementAt(i);
//HidDevice tempDev = DisabledDevices.ElementAt(i);
HidDevice tempDev = devEnum.Current;
if (tempDev != null)
{
if (tempDev.IsOpen && tempDev.IsConnected)

View File

@ -46,9 +46,11 @@ namespace DS4Windows
List<HidDevice> foundDevs = new List<HidDevice>();
int devInfoLen = devInfo.Length;
IEnumerable<DeviceInfo> temp = EnumerateDevices();
for (int i = 0, len = temp.Count(); i < len; i++)
for (var devEnum = temp.GetEnumerator(); devEnum.MoveNext();)
//for (int i = 0, len = temp.Count(); i < len; i++)
{
DeviceInfo x = temp.ElementAt(i);
DeviceInfo x = devEnum.Current;
//DeviceInfo x = temp.ElementAt(i);
HidDevice tempDev = new HidDevice(x.Path, x.Description);
bool found = false;
for (int j = 0; !found && j < devInfoLen; j++)