Convert part of loop body into LINQ expression.

This commit is contained in:
2023-10-04 08:43:23 +01:00
parent 4ad10115ef
commit 490d4a48c9
4 changed files with 12 additions and 19 deletions

View File

@@ -275,13 +275,9 @@ public sealed partial class A2R
string[] metaFields = metaData.Split('\n');
foreach(string field in metaFields)
{
string[] keyValue = field.Split('\t');
if(keyValue.Length == 2)
foreach(string[] keyValue in metaFields.Select(field => field.Split('\t')).
Where(keyValue => keyValue.Length == 2))
Meta.Add(keyValue[0], keyValue[1]);
}
if(Meta.TryGetValue("image_date", out string imageDate))
_imageInfo.CreationTime = DateTime.Parse(imageDate);

View File

@@ -174,14 +174,13 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest
bool useLong = inputFormat.Info.ReadableSectorTags.Except(new[] { SectorTagType.CdTrackFlags }).Any();
foreach(SectorTagType sectorTag in inputFormat.Info.ReadableSectorTags.Where(sectorTag =>
!outputFormat.SupportedSectorTags.Contains(sectorTag)))
{
if(sectorTag != SectorTagType.CdTrackFlags &&
// TODO: Can be done with LINQ only
foreach(SectorTagType _ in inputFormat.Info.ReadableSectorTags.Where(sectorTag =>
!outputFormat.SupportedSectorTags.Contains(sectorTag)).Where(
sectorTag => sectorTag != SectorTagType.CdTrackFlags &&
sectorTag != SectorTagType.CdTrackIsrc &&
sectorTag != SectorTagType.CdSectorSubchannel)
sectorTag != SectorTagType.CdSectorSubchannel))
useLong = false;
}
Assert.IsTrue(
outputFormat.Create(outputPath, inputFormat.Info.MediaType, new Dictionary<string, string>(),
@@ -455,10 +454,8 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest
if(trackFlags.Count > 0)
{
foreach((byte track, byte flags) in trackFlags)
{
outputFormat.WriteSectorTag(new[] { flags }, track, SectorTagType.CdTrackFlags);
}
}
if(mcn != null)
outputFormat.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN);