mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Convert to switch expression.
This commit is contained in:
125
SCSI/EVPD.cs
125
SCSI/EVPD.cs
@@ -254,18 +254,16 @@ public static class EVPD
|
||||
|
||||
public static string PrettifyPage_81(byte[] pageResponse) => PrettifyPage_81(DecodePage_81(pageResponse));
|
||||
|
||||
public static string DefinitionToString(ScsiDefinitions definition)
|
||||
{
|
||||
switch(definition)
|
||||
{
|
||||
case ScsiDefinitions.Current: return "";
|
||||
case ScsiDefinitions.CCS: return "CCS";
|
||||
case ScsiDefinitions.SCSI1: return "SCSI-1";
|
||||
case ScsiDefinitions.SCSI2: return "SCSI-2";
|
||||
case ScsiDefinitions.SCSI3: return "SCSI-3";
|
||||
default: return $"Unknown definition code {(byte)definition}";
|
||||
}
|
||||
}
|
||||
public static string DefinitionToString(ScsiDefinitions definition) => definition switch
|
||||
{
|
||||
ScsiDefinitions.Current => "",
|
||||
ScsiDefinitions.CCS => "CCS",
|
||||
ScsiDefinitions.SCSI1 => "SCSI-1",
|
||||
ScsiDefinitions.SCSI2 => "SCSI-2",
|
||||
ScsiDefinitions.SCSI3 => "SCSI-3",
|
||||
_ => $"Unknown definition code {
|
||||
(byte)definition}"
|
||||
};
|
||||
|
||||
public static string PrettifyPage_81(Page_81? modePage)
|
||||
{
|
||||
@@ -416,21 +414,12 @@ public static class EVPD
|
||||
|
||||
Array.Copy(pageResponse, position + 4, descriptor.Binary, 0, descriptor.Length);
|
||||
|
||||
switch(descriptor.CodeSet)
|
||||
{
|
||||
case IdentificationCodeSet.ASCII:
|
||||
descriptor.ASCII = StringHandlers.CToString(descriptor.Binary);
|
||||
|
||||
break;
|
||||
case IdentificationCodeSet.UTF8:
|
||||
descriptor.ASCII = Encoding.UTF8.GetString(descriptor.Binary);
|
||||
|
||||
break;
|
||||
default:
|
||||
descriptor.ASCII = "";
|
||||
|
||||
break;
|
||||
}
|
||||
descriptor.ASCII = descriptor.CodeSet switch
|
||||
{
|
||||
IdentificationCodeSet.ASCII => StringHandlers.CToString(descriptor.Binary),
|
||||
IdentificationCodeSet.UTF8 => Encoding.UTF8.GetString(descriptor.Binary),
|
||||
_ => ""
|
||||
};
|
||||
|
||||
position += 4 + descriptor.Length;
|
||||
descriptors.Add(descriptor);
|
||||
@@ -485,67 +474,23 @@ public static class EVPD
|
||||
|
||||
if(descriptor.PIV)
|
||||
{
|
||||
string protocol;
|
||||
|
||||
switch(descriptor.ProtocolIdentifier)
|
||||
{
|
||||
case ProtocolIdentifiers.ADT:
|
||||
protocol = "Automation/Drive Interface Transport";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.ATA:
|
||||
protocol = "AT Attachment Interface (ATA/ATAPI)";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.FibreChannel:
|
||||
protocol = "Fibre Channel";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.Firewire:
|
||||
protocol = "IEEE 1394";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.iSCSI:
|
||||
protocol = "Internet SCSI";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.NoProtocol:
|
||||
protocol = "no specific";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.PCIe:
|
||||
protocol = "PCI Express";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.RDMAP:
|
||||
protocol = "SCSI Remote Direct Memory Access";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.SAS:
|
||||
protocol = "Serial Attachment SCSI";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.SCSI:
|
||||
protocol = "Parallel SCSI";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.SCSIe:
|
||||
protocol = "SCSI over PCI Express";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.SSA:
|
||||
protocol = "SSA";
|
||||
|
||||
break;
|
||||
case ProtocolIdentifiers.UAS:
|
||||
protocol = "USB Attached SCSI";
|
||||
|
||||
break;
|
||||
default:
|
||||
protocol = $"unknown code {(byte)descriptor.ProtocolIdentifier}";
|
||||
|
||||
break;
|
||||
}
|
||||
string protocol = descriptor.ProtocolIdentifier switch
|
||||
{
|
||||
ProtocolIdentifiers.ADT => "Automation/Drive Interface Transport",
|
||||
ProtocolIdentifiers.ATA => "AT Attachment Interface (ATA/ATAPI)",
|
||||
ProtocolIdentifiers.FibreChannel => "Fibre Channel",
|
||||
ProtocolIdentifiers.Firewire => "IEEE 1394",
|
||||
ProtocolIdentifiers.iSCSI => "Internet SCSI",
|
||||
ProtocolIdentifiers.NoProtocol => "no specific",
|
||||
ProtocolIdentifiers.PCIe => "PCI Express",
|
||||
ProtocolIdentifiers.RDMAP => "SCSI Remote Direct Memory Access",
|
||||
ProtocolIdentifiers.SAS => "Serial Attachment SCSI",
|
||||
ProtocolIdentifiers.SCSI => "Parallel SCSI",
|
||||
ProtocolIdentifiers.SCSIe => "SCSI over PCI Express",
|
||||
ProtocolIdentifiers.SSA => "SSA",
|
||||
ProtocolIdentifiers.UAS => "USB Attached SCSI",
|
||||
_ => $"unknown code {(byte)descriptor.ProtocolIdentifier}"
|
||||
};
|
||||
|
||||
sb.AppendFormat("\tDescriptor referes to {0} protocol", protocol).AppendLine();
|
||||
}
|
||||
@@ -1014,8 +959,8 @@ public static class EVPD
|
||||
|
||||
break;
|
||||
default:
|
||||
sb.AppendFormat("\tIdentifier has unknown association with code {0}",
|
||||
(byte)descriptor.Association).AppendLine();
|
||||
sb.AppendFormat("\tIdentifier has unknown association with code {0}", (byte)descriptor.Association).
|
||||
AppendLine();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -354,14 +354,13 @@ public static class DiscInformation
|
||||
if(response.Length < 12)
|
||||
return null;
|
||||
|
||||
switch(response[2] & 0xE0)
|
||||
{
|
||||
case 0x00: return Prettify000b(Decode000b(response));
|
||||
case 0x20: return Prettify001b(Decode001b(response));
|
||||
case 0x40: return Prettify010b(Decode010b(response));
|
||||
}
|
||||
|
||||
return null;
|
||||
return (response[2] & 0xE0) switch
|
||||
{
|
||||
0x00 => Prettify000b(Decode000b(response)),
|
||||
0x20 => Prettify001b(Decode001b(response)),
|
||||
0x40 => Prettify010b(Decode010b(response)),
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
public struct StandardDiscInformation
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -187,14 +187,14 @@ public static class Sense
|
||||
if((sense[0] & 0x70) != 0x70)
|
||||
return sense.Length != 4 ? SenseType.Invalid : SenseType.StandardSense;
|
||||
|
||||
switch(sense[0] & 0x0F)
|
||||
{
|
||||
case 0: return SenseType.ExtendedSenseFixedCurrent;
|
||||
case 1: return SenseType.ExtendedSenseFixedPast;
|
||||
case 2: return SenseType.ExtendedSenseDescriptorCurrent;
|
||||
case 3: return SenseType.ExtendedSenseDescriptorPast;
|
||||
default: return SenseType.Unknown;
|
||||
}
|
||||
return (sense[0] & 0x0F) switch
|
||||
{
|
||||
0 => SenseType.ExtendedSenseFixedCurrent,
|
||||
1 => SenseType.ExtendedSenseFixedPast,
|
||||
2 => SenseType.ExtendedSenseDescriptorCurrent,
|
||||
3 => SenseType.ExtendedSenseDescriptorPast,
|
||||
_ => SenseType.Unknown
|
||||
};
|
||||
}
|
||||
|
||||
public static StandardSense? DecodeStandard(byte[] sense)
|
||||
@@ -593,28 +593,25 @@ public static class Sense
|
||||
public static string PrettifyDescriptor00(byte[] descriptor) =>
|
||||
PrettifyDescriptor00(DecodeDescriptor00(descriptor));
|
||||
|
||||
public static string GetSenseKey(SenseKeys key)
|
||||
{
|
||||
switch(key)
|
||||
{
|
||||
case SenseKeys.AbortedCommand: return "ABORTED COMMAND";
|
||||
case SenseKeys.BlankCheck: return "BLANK CHECK";
|
||||
case SenseKeys.CopyAborted: return "COPY ABORTED";
|
||||
case SenseKeys.DataProtect: return "DATA PROTECT";
|
||||
case SenseKeys.Equal: return "EQUAL";
|
||||
case SenseKeys.HardwareError: return "HARDWARE ERROR";
|
||||
case SenseKeys.IllegalRequest: return "ILLEGAL REQUEST";
|
||||
case SenseKeys.MediumError: return "MEDIUM ERROR";
|
||||
case SenseKeys.Miscompare: return "MISCOMPARE";
|
||||
case SenseKeys.NoSense: return "NO SENSE";
|
||||
case SenseKeys.PrivateUse: return "PRIVATE USE";
|
||||
case SenseKeys.RecoveredError: return "RECOVERED ERROR";
|
||||
case SenseKeys.Completed: return "COMPLETED";
|
||||
case SenseKeys.UnitAttention: return "UNIT ATTENTION";
|
||||
case SenseKeys.VolumeOverflow: return "VOLUME OVERFLOW";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
public static string GetSenseKey(SenseKeys key) => key switch
|
||||
{
|
||||
SenseKeys.AbortedCommand => "ABORTED COMMAND",
|
||||
SenseKeys.BlankCheck => "BLANK CHECK",
|
||||
SenseKeys.CopyAborted => "COPY ABORTED",
|
||||
SenseKeys.DataProtect => "DATA PROTECT",
|
||||
SenseKeys.Equal => "EQUAL",
|
||||
SenseKeys.HardwareError => "HARDWARE ERROR",
|
||||
SenseKeys.IllegalRequest => "ILLEGAL REQUEST",
|
||||
SenseKeys.MediumError => "MEDIUM ERROR",
|
||||
SenseKeys.Miscompare => "MISCOMPARE",
|
||||
SenseKeys.NoSense => "NO SENSE",
|
||||
SenseKeys.PrivateUse => "PRIVATE USE",
|
||||
SenseKeys.RecoveredError => "RECOVERED ERROR",
|
||||
SenseKeys.Completed => "COMPLETED",
|
||||
SenseKeys.UnitAttention => "UNIT ATTENTION",
|
||||
SenseKeys.VolumeOverflow => "VOLUME OVERFLOW",
|
||||
_ => "UNKNOWN"
|
||||
};
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static string GetSenseDescription(byte ASC, byte ASCQ)
|
||||
@@ -1431,11 +1428,11 @@ public static class Sense
|
||||
|
||||
break;
|
||||
case 0x40:
|
||||
switch(ASCQ)
|
||||
{
|
||||
case 0x00: return "RAM FAILURE";
|
||||
default: return $"DIAGNOSTIC FAILURE ON COMPONENT {ASCQ:X2}h";
|
||||
}
|
||||
return ASCQ switch
|
||||
{
|
||||
0x00 => "RAM FAILURE",
|
||||
_ => $"DIAGNOSTIC FAILURE ON COMPONENT {ASCQ:X2}h"
|
||||
};
|
||||
case 0x41:
|
||||
switch(ASCQ)
|
||||
{
|
||||
|
||||
1607
SCSI/VendorString.cs
1607
SCSI/VendorString.cs
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user