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'); string[] metaFields = metaData.Split('\n');
foreach(string field in metaFields) foreach(string[] keyValue in metaFields.Select(field => field.Split('\t')).
{ Where(keyValue => keyValue.Length == 2))
string[] keyValue = field.Split('\t');
if(keyValue.Length == 2)
Meta.Add(keyValue[0], keyValue[1]); Meta.Add(keyValue[0], keyValue[1]);
}
if(Meta.TryGetValue("image_date", out string imageDate)) if(Meta.TryGetValue("image_date", out string imageDate))
_imageInfo.CreationTime = DateTime.Parse(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(); bool useLong = inputFormat.Info.ReadableSectorTags.Except(new[] { SectorTagType.CdTrackFlags }).Any();
foreach(SectorTagType sectorTag in inputFormat.Info.ReadableSectorTags.Where(sectorTag => // TODO: Can be done with LINQ only
!outputFormat.SupportedSectorTags.Contains(sectorTag))) foreach(SectorTagType _ in inputFormat.Info.ReadableSectorTags.Where(sectorTag =>
{ !outputFormat.SupportedSectorTags.Contains(sectorTag)).Where(
if(sectorTag != SectorTagType.CdTrackFlags && sectorTag => sectorTag != SectorTagType.CdTrackFlags &&
sectorTag != SectorTagType.CdTrackIsrc && sectorTag != SectorTagType.CdTrackIsrc &&
sectorTag != SectorTagType.CdSectorSubchannel) sectorTag != SectorTagType.CdSectorSubchannel))
useLong = false; useLong = false;
}
Assert.IsTrue( Assert.IsTrue(
outputFormat.Create(outputPath, inputFormat.Info.MediaType, new Dictionary<string, string>(), outputFormat.Create(outputPath, inputFormat.Info.MediaType, new Dictionary<string, string>(),
@@ -455,10 +454,8 @@ public abstract class WritableOpticalMediaImageTest : BaseWritableMediaImageTest
if(trackFlags.Count > 0) if(trackFlags.Count > 0)
{ {
foreach((byte track, byte flags) in trackFlags) foreach((byte track, byte flags) in trackFlags)
{
outputFormat.WriteSectorTag(new[] { flags }, track, SectorTagType.CdTrackFlags); outputFormat.WriteSectorTag(new[] { flags }, track, SectorTagType.CdTrackFlags);
} }
}
if(mcn != null) if(mcn != null)
outputFormat.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN); outputFormat.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN);