mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Convert if to switch statement.
This commit is contained in:
@@ -163,16 +163,25 @@ public static partial class Modes
|
||||
if(page.POFM)
|
||||
sb.AppendLine("\tPartition parameters will not be applied until a FORMAT MEDIUM command is received");
|
||||
|
||||
if(!page.CLEAR &&
|
||||
!page.ADDP)
|
||||
sb.AppendLine("\tDevice may erase any or all partitions on MODE SELECT for partitioning");
|
||||
else if(page.CLEAR &&
|
||||
!page.ADDP)
|
||||
sb.AppendLine("\tDevice shall erase all partitions on MODE SELECT for partitioning");
|
||||
else if(!page.CLEAR)
|
||||
sb.AppendLine("\tDevice shall not erase any partition on MODE SELECT for partitioning");
|
||||
else
|
||||
sb.AppendLine("\tDevice shall erase all partitions differing on size on MODE SELECT for partitioning");
|
||||
switch(page.CLEAR)
|
||||
{
|
||||
case false when !page.ADDP:
|
||||
sb.AppendLine("\tDevice may erase any or all partitions on MODE SELECT for partitioning");
|
||||
|
||||
break;
|
||||
case true when !page.ADDP:
|
||||
sb.AppendLine("\tDevice shall erase all partitions on MODE SELECT for partitioning");
|
||||
|
||||
break;
|
||||
case false:
|
||||
sb.AppendLine("\tDevice shall not erase any partition on MODE SELECT for partitioning");
|
||||
|
||||
break;
|
||||
default:
|
||||
sb.AppendLine("\tDevice shall erase all partitions differing on size on MODE SELECT for partitioning");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
string measure;
|
||||
|
||||
|
||||
@@ -187,14 +187,19 @@ public static partial class Modes
|
||||
sb.AppendLine("\tDrive contains a changer that can report the exact contents of the slots");
|
||||
|
||||
if(page.CurrentWriteSpeedSelected > 0)
|
||||
{
|
||||
if(page.RotationControlSelected == 0)
|
||||
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec. in CLV mode",
|
||||
page.CurrentWriteSpeedSelected).AppendLine();
|
||||
else if(page.RotationControlSelected == 1)
|
||||
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec. in pure CAV mode",
|
||||
page.CurrentWriteSpeedSelected).AppendLine();
|
||||
}
|
||||
switch(page.RotationControlSelected)
|
||||
{
|
||||
case 0:
|
||||
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec. in CLV mode",
|
||||
page.CurrentWriteSpeedSelected).AppendLine();
|
||||
|
||||
break;
|
||||
case 1:
|
||||
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec. in pure CAV mode",
|
||||
page.CurrentWriteSpeedSelected).AppendLine();
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(page.MaxWriteSpeed > 0)
|
||||
@@ -208,12 +213,19 @@ public static partial class Modes
|
||||
if(page.WriteSpeedPerformanceDescriptors != null)
|
||||
foreach(ModePage_2A_WriteDescriptor descriptor in page.WriteSpeedPerformanceDescriptors.Where(descriptor =>
|
||||
descriptor.WriteSpeed > 0))
|
||||
if(descriptor.RotationControl == 0)
|
||||
sb.AppendFormat("\tDrive supports writing at {0} Kbyte/sec. in CLV mode", descriptor.WriteSpeed).
|
||||
AppendLine();
|
||||
else if(descriptor.RotationControl == 1)
|
||||
sb.AppendFormat("\tDrive supports writing at is {0} Kbyte/sec. in pure CAV mode",
|
||||
descriptor.WriteSpeed).AppendLine();
|
||||
switch(descriptor.RotationControl)
|
||||
{
|
||||
case 0:
|
||||
sb.AppendFormat("\tDrive supports writing at {0} Kbyte/sec. in CLV mode",
|
||||
descriptor.WriteSpeed).AppendLine();
|
||||
|
||||
break;
|
||||
case 1:
|
||||
sb.AppendFormat("\tDrive supports writing at is {0} Kbyte/sec. in pure CAV mode",
|
||||
descriptor.WriteSpeed).AppendLine();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(page.TestWrite)
|
||||
sb.AppendLine("\tDrive supports test writing");
|
||||
|
||||
@@ -200,36 +200,43 @@ public static partial class Modes
|
||||
offset += pg.PageResponse.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isSubpage && offset + 3 < modeResponse.Length)
|
||||
switch(isSubpage)
|
||||
{
|
||||
pg.PageResponse = new byte[(modeResponse[offset + 2] << 8) + modeResponse[offset + 3] + 4];
|
||||
int copyLen = pg.PageResponse.Length;
|
||||
case true when offset + 3 < modeResponse.Length:
|
||||
{
|
||||
pg.PageResponse = new byte[(modeResponse[offset + 2] << 8) + modeResponse[offset + 3] + 4];
|
||||
int copyLen = pg.PageResponse.Length;
|
||||
|
||||
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
||||
copyLen = modeResponse.Length - offset;
|
||||
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
||||
copyLen = modeResponse.Length - offset;
|
||||
|
||||
Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen);
|
||||
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
||||
pg.Subpage = modeResponse[offset + 1];
|
||||
offset += pg.PageResponse.Length;
|
||||
Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen);
|
||||
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
||||
pg.Subpage = modeResponse[offset + 1];
|
||||
offset += pg.PageResponse.Length;
|
||||
|
||||
break;
|
||||
}
|
||||
case true when offset + 1 < modeResponse.Length:
|
||||
{
|
||||
pg.PageResponse = new byte[modeResponse[offset + 1] + 2];
|
||||
int copyLen = pg.PageResponse.Length;
|
||||
|
||||
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
||||
copyLen = modeResponse.Length - offset;
|
||||
|
||||
Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen);
|
||||
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
||||
pg.Subpage = 0;
|
||||
offset += pg.PageResponse.Length;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
offset = modeResponse.Length;
|
||||
|
||||
break;
|
||||
}
|
||||
else if(isSubpage && offset + 1 < modeResponse.Length)
|
||||
{
|
||||
pg.PageResponse = new byte[modeResponse[offset + 1] + 2];
|
||||
int copyLen = pg.PageResponse.Length;
|
||||
|
||||
if(pg.PageResponse.Length + offset > modeResponse.Length)
|
||||
copyLen = modeResponse.Length - offset;
|
||||
|
||||
Array.Copy(modeResponse, offset, pg.PageResponse, 0, copyLen);
|
||||
pg.Page = (byte)(modeResponse[offset] & 0x3F);
|
||||
pg.Subpage = 0;
|
||||
offset += pg.PageResponse.Length;
|
||||
}
|
||||
else
|
||||
offset = modeResponse.Length;
|
||||
}
|
||||
|
||||
listpages.Add(pg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user