REFACTOR: Use string interpolation expression.

This commit is contained in:
2017-12-21 17:58:51 +00:00
parent a895700757
commit 4e6e8f340a
182 changed files with 766 additions and 1256 deletions

View File

@@ -145,7 +145,7 @@ namespace DiscImageChef.Core.Devices.Dumping
sidecar.BlockMedia[0].PCMCIA.Manufacturer = vers.Manufacturer;
sidecar.BlockMedia[0].PCMCIA.ProductName = vers.Product;
sidecar.BlockMedia[0].PCMCIA.Compliance =
string.Format("{0}.{1}", vers.MajorVersion, vers.MinorVersion);
$"{vers.MajorVersion}.{vers.MinorVersion}";
sidecar.BlockMedia[0].PCMCIA.AdditionalInformation = vers.AdditionalInformation;
}
break;

View File

@@ -277,7 +277,7 @@ namespace DiscImageChef.Core.Devices.Dumping
if(trk.PHOUR > 0)
track.StartMSF = string.Format("{3:D2}:{0:D2}:{1:D2}:{2:D2}", trk.PMIN, trk.PSEC,
trk.PFRAME, trk.PHOUR);
else track.StartMSF = string.Format("{0:D2}:{1:D2}:{2:D2}", trk.PMIN, trk.PSEC, trk.PFRAME);
else track.StartMSF = $"{trk.PMIN:D2}:{trk.PSEC:D2}:{trk.PFRAME:D2}";
track.StartSector = trk.PHOUR * 3600 * 75 + trk.PMIN * 60 * 75 + trk.PSEC * 75 + trk.PFRAME -
150;
trackList.Add(track);
@@ -320,7 +320,7 @@ namespace DiscImageChef.Core.Devices.Dumping
}
if(phour > 0) lastMsf = string.Format("{3:D2}:{0:D2}:{1:D2}:{2:D2}", pmin, psec, pframe, phour);
else lastMsf = string.Format("{0:D2}:{1:D2}:{2:D2}", pmin, psec, pframe);
else lastMsf = $"{pmin:D2}:{psec:D2}:{pframe:D2}";
lastSector = phour * 3600 * 75 + pmin * 60 * 75 + psec * 75 + pframe - 150;
}
@@ -349,7 +349,7 @@ namespace DiscImageChef.Core.Devices.Dumping
if(phour > 0)
tracks[t - 1].EndMSF = string.Format("{3:D2}:{0:D2}:{1:D2}:{2:D2}", pmin, psec, pframe, phour);
else tracks[t - 1].EndMSF = string.Format("{0:D2}:{1:D2}:{2:D2}", pmin, psec, pframe);
else tracks[t - 1].EndMSF = $"{pmin:D2}:{psec:D2}:{pframe:D2}";
}
tracks[tracks.Length - 1].EndMSF = lastMsf;

View File

@@ -51,31 +51,25 @@ namespace DiscImageChef.Core.Devices.Dumping
if(resume.Removable != removable)
throw new
Exception(string.Format("Resume file specifies a {0} device but you're requesting to dump a {1} device, not continuing...",
resume.Removable ? "removable" : "non removable",
removable ? "removable" : "non removable"));
Exception($"Resume file specifies a {(resume.Removable ? "removable" : "non removable")} device but you're requesting to dump a {(removable ? "removable" : "non removable")} device, not continuing...");
if(resume.LastBlock != blocks - 1)
throw new
Exception(string.Format("Resume file specifies a device with {0} blocks but you're requesting to dump one with {1} blocks, not continuing...",
resume.LastBlock + 1, blocks));
Exception($"Resume file specifies a device with {resume.LastBlock + 1} blocks but you're requesting to dump one with {blocks} blocks, not continuing...");
foreach(DumpHardwareType oldtry in resume.Tries)
{
if(oldtry.Manufacturer != manufacturer && !removable)
throw new
Exception(string.Format("Resume file specifies a device manufactured by {0} but you're requesting to dump one by {1}, not continuing...",
oldtry.Manufacturer, manufacturer));
Exception($"Resume file specifies a device manufactured by {oldtry.Manufacturer} but you're requesting to dump one by {manufacturer}, not continuing...");
if(oldtry.Model != model && !removable)
throw new
Exception(string.Format("Resume file specifies a device model {0} but you're requesting to dump model {1}, not continuing...",
oldtry.Model, model));
Exception($"Resume file specifies a device model {oldtry.Model} but you're requesting to dump model {model}, not continuing...");
if(oldtry.Serial != serial && !removable)
throw new
Exception(string.Format("Resume file specifies a device with serial {0} but you're requesting to dump one with serial {1}, not continuing...",
oldtry.Serial, serial));
Exception($"Resume file specifies a device with serial {oldtry.Serial} but you're requesting to dump one with serial {serial}, not continuing...");
if(oldtry.Software == null) throw new Exception("Found corrupt resume file, cannot continue...");

View File

@@ -220,7 +220,7 @@ namespace DiscImageChef.Core.Devices.Dumping
EVPDType evpd = new EVPDType
{
Image = string.Format("{0}.evpd_{1:X2}h.bin", outputPrefix, page),
Image = $"{outputPrefix}.evpd_{page:X2}h.bin",
Checksums = Checksum.GetChecksums(cmdBuf).ToArray(),
Size = cmdBuf.Length
};

View File

@@ -82,7 +82,7 @@ namespace DiscImageChef.Core.Devices
case DeviceType.ATAPI:
case DeviceType.SCSI: return ScsiGetBlocks();
default:
ErrorMessage = string.Format("Unknown device type {0}.", dev.Type);
ErrorMessage = $"Unknown device type {dev.Type}.";
return 0;
}
}
@@ -95,7 +95,7 @@ namespace DiscImageChef.Core.Devices
case DeviceType.ATAPI:
case DeviceType.SCSI: return ScsiFindReadCommand();
default:
ErrorMessage = string.Format("Unknown device type {0}.", dev.Type);
ErrorMessage = $"Unknown device type {dev.Type}.";
return true;
}
}
@@ -108,7 +108,7 @@ namespace DiscImageChef.Core.Devices
case DeviceType.ATAPI:
case DeviceType.SCSI: return ScsiGetBlockSize();
default:
ErrorMessage = string.Format("Unknown device type {0}.", dev.Type);
ErrorMessage = $"Unknown device type {dev.Type}.";
return true;
}
}
@@ -121,7 +121,7 @@ namespace DiscImageChef.Core.Devices
case DeviceType.ATAPI:
case DeviceType.SCSI: return ScsiGetBlocksToRead(startWithBlocks);
default:
ErrorMessage = string.Format("Unknown device type {0}.", dev.Type);
ErrorMessage = $"Unknown device type {dev.Type}.";
return true;
}
}

View File

@@ -265,7 +265,7 @@ namespace DiscImageChef.Core.Devices
if(!error || !IsLba) return false;
BlocksToRead = 1;
ErrorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError);
ErrorMessage = $"Device error {dev.LastError} trying to guess ideal transfer length.";
return true;
}

View File

@@ -88,16 +88,14 @@ namespace DiscImageChef.Core.Devices
if(read6 && !read10 && !read12 && !read16 && Blocks > 0x001FFFFF + 1)
{
ErrorMessage =
string.Format("Device only supports SCSI READ (6) but has more than {0} blocks ({1} blocks total)",
0x001FFFFF + 1, Blocks);
$"Device only supports SCSI READ (6) but has more than {0x001FFFFF + 1} blocks ({Blocks} blocks total)";
return true;
}
if(!read16 && Blocks > 0xFFFFFFFF + (long)1)
{
ErrorMessage =
string.Format("Device only supports SCSI READ (10) but has more than {0} blocks ({1} blocks total)",
0xFFFFFFFF + (long)1, Blocks);
$"Device only supports SCSI READ (10) but has more than {0xFFFFFFFF + (long)1} blocks ({Blocks} blocks total)";
return true;
}
@@ -403,8 +401,7 @@ namespace DiscImageChef.Core.Devices
if(sense && Blocks == 0)
if(dev.ScsiType != PeripheralDeviceTypes.MultiMediaDevice)
{
ErrorMessage = string.Format("Unable to get media capacity\n" + "{0}",
Sense.PrettifySense(senseBuf));
ErrorMessage = "Unable to get media capacity\n" + $"{Sense.PrettifySense(senseBuf)}";
return true;
}
@@ -465,7 +462,7 @@ namespace DiscImageChef.Core.Devices
if(!dev.Error) return false;
BlocksToRead = 1;
ErrorMessage = string.Format("Device error {0} trying to guess ideal transfer length.", dev.LastError);
ErrorMessage = $"Device error {dev.LastError} trying to guess ideal transfer length.";
return true;
}

View File

@@ -65,7 +65,7 @@ namespace DiscImageChef.Core.Devices.Report
{
report.PCMCIA.Manufacturer = vers.Manufacturer;
report.PCMCIA.ProductName = vers.Product;
report.PCMCIA.Compliance = string.Format("{0}.{1}", vers.MajorVersion, vers.MinorVersion);
report.PCMCIA.Compliance = $"{vers.MajorVersion}.{vers.MinorVersion}";
report.PCMCIA.AdditionalInformation = vers.AdditionalInformation;
}
break;

View File

@@ -887,7 +887,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(debug)
{
FileStream bingo =
new FileStream(string.Format("{0}_readlong.bin", dev.Model),
new FileStream($"{dev.Model}_readlong.bin",
FileMode.Create);
bingo.Write(buffer, 0, buffer.Length);
bingo.Close();

View File

@@ -1917,7 +1917,7 @@ namespace DiscImageChef.Core.Devices.Report.SCSI
if(debug)
{
FileStream bingo =
new FileStream(string.Format("{0}_readlong.bin", mediaType),
new FileStream($"{mediaType}_readlong.bin",
FileMode.Create);
bingo.Write(buffer, 0, buffer.Length);
bingo.Close();