mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
REFACTOR: Loop can be converted into LINQ-expression.
This commit is contained in:
@@ -908,12 +908,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
public override byte[] ReadSectors(ulong sectorAddress, uint length)
|
||||
{
|
||||
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
|
||||
if(sectorAddress >= kvp.Value)
|
||||
foreach(Track _track in tracks)
|
||||
if(_track.TrackSequence == kvp.Key)
|
||||
if(sectorAddress <= _track.TrackEndSector)
|
||||
return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key);
|
||||
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap where sectorAddress >= kvp.Value from _track in tracks where _track.TrackSequence == kvp.Key where sectorAddress <= _track.TrackEndSector select kvp) return ReadSectors(sectorAddress - kvp.Value, length, kvp.Key);
|
||||
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
|
||||
string.Format("Sector address {0} not found", sectorAddress));
|
||||
@@ -921,12 +916,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
public override byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
|
||||
{
|
||||
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
|
||||
if(sectorAddress >= kvp.Value)
|
||||
foreach(Track _track in tracks)
|
||||
if(_track.TrackSequence == kvp.Key)
|
||||
if(sectorAddress <= _track.TrackEndSector)
|
||||
return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
|
||||
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap where sectorAddress >= kvp.Value from _track in tracks where _track.TrackSequence == kvp.Key where sectorAddress <= _track.TrackEndSector select kvp) return ReadSectorsTag(sectorAddress - kvp.Value, length, kvp.Key, tag);
|
||||
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
|
||||
string.Format("Sector address {0} not found", sectorAddress));
|
||||
@@ -938,12 +928,10 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
_track.TrackSequence = 0;
|
||||
|
||||
foreach(Track __track in tracks)
|
||||
if(__track.TrackSequence == track)
|
||||
{
|
||||
_track = __track;
|
||||
break;
|
||||
}
|
||||
foreach(Track __track in tracks.Where(__track => __track.TrackSequence == track)) {
|
||||
_track = __track;
|
||||
break;
|
||||
}
|
||||
|
||||
if(_track.TrackSequence == 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
|
||||
@@ -1023,12 +1011,10 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
_track.TrackSequence = 0;
|
||||
|
||||
foreach(Track __track in tracks)
|
||||
if(__track.TrackSequence == track)
|
||||
{
|
||||
_track = __track;
|
||||
break;
|
||||
}
|
||||
foreach(Track __track in tracks.Where(__track => __track.TrackSequence == track)) {
|
||||
_track = __track;
|
||||
break;
|
||||
}
|
||||
|
||||
if(_track.TrackSequence == 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
|
||||
@@ -1274,12 +1260,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
public override byte[] ReadSectorsLong(ulong sectorAddress, uint length)
|
||||
{
|
||||
foreach(KeyValuePair<uint, ulong> kvp in offsetmap)
|
||||
if(sectorAddress >= kvp.Value)
|
||||
foreach(Track track in tracks)
|
||||
if(track.TrackSequence == kvp.Key)
|
||||
if(sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1)
|
||||
return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key);
|
||||
foreach(KeyValuePair<uint, ulong> kvp in from kvp in offsetmap where sectorAddress >= kvp.Value from track in tracks where track.TrackSequence == kvp.Key where sectorAddress - kvp.Value < track.TrackEndSector - track.TrackStartSector + 1 select kvp) return ReadSectorsLong(sectorAddress - kvp.Value, length, kvp.Key);
|
||||
|
||||
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
|
||||
string.Format("Sector address {0} not found", sectorAddress));
|
||||
@@ -1291,12 +1272,10 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
_track.TrackSequence = 0;
|
||||
|
||||
foreach(Track __track in tracks)
|
||||
if(__track.TrackSequence == track)
|
||||
{
|
||||
_track = __track;
|
||||
break;
|
||||
}
|
||||
foreach(Track __track in tracks.Where(__track => __track.TrackSequence == track)) {
|
||||
_track = __track;
|
||||
break;
|
||||
}
|
||||
|
||||
if(_track.TrackSequence == 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(track), "Track does not exist in disc image");
|
||||
@@ -1434,10 +1413,7 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
public override List<Track> GetSessionTracks(ushort session)
|
||||
{
|
||||
List<Track> tracks = new List<Track>();
|
||||
foreach(Track _track in this.tracks) if(_track.TrackSession == session) tracks.Add(_track);
|
||||
|
||||
return tracks;
|
||||
return this.tracks.Where(_track => _track.TrackSession == session).ToList();
|
||||
}
|
||||
|
||||
public override List<DiscImages.Session> GetSessions()
|
||||
|
||||
Reference in New Issue
Block a user