More pattern matching.

This commit is contained in:
2022-11-14 01:49:09 +00:00
parent e6db6032f3
commit a02220902c
8 changed files with 11 additions and 22 deletions

View File

@@ -57,8 +57,7 @@ public static class ATIP
{
public static CDATIP Decode(byte[] CDATIPResponse)
{
if(CDATIPResponse == null ||
CDATIPResponse.Length <= 4)
if(CDATIPResponse is not { Length: > 4 })
return null;
var decoded = new CDATIP();

View File

@@ -93,8 +93,7 @@ public static class CDTextOnLeadIn
public static CDText? Decode(byte[] CDTextResponse)
{
if(CDTextResponse == null ||
CDTextResponse.Length <= 4)
if(CDTextResponse is not { Length: > 4 })
return null;
var decoded = new CDText

View File

@@ -69,8 +69,7 @@ public static class FullTOC
public static CDFullTOC? Decode(byte[] CDFullTOCResponse)
{
if(CDFullTOCResponse == null ||
CDFullTOCResponse.Length <= 4)
if(CDFullTOCResponse is not { Length: > 4 })
return null;
var decoded = new CDFullTOC

View File

@@ -56,8 +56,7 @@ public static class PMA
{
public static CDPMA? Decode(byte[] CDPMAResponse)
{
if(CDPMAResponse == null ||
CDPMAResponse.Length <= 4)
if(CDPMAResponse is not { Length: > 4 })
return null;
var decoded = new CDPMA

View File

@@ -55,8 +55,7 @@ public static class Session
{
public static CDSessionInfo? Decode(byte[] CDSessionInfoResponse)
{
if(CDSessionInfoResponse == null ||
CDSessionInfoResponse.Length <= 4)
if(CDSessionInfoResponse is not { Length: > 4 })
return null;
var decoded = new CDSessionInfo

View File

@@ -58,8 +58,7 @@ public static class TOC
{
public static CDTOC? Decode(byte[] CDTOCResponse)
{
if(CDTOCResponse == null ||
CDTOCResponse.Length <= 4)
if(CDTOCResponse is not { Length: > 4 })
return null;
var decoded = new CDTOC

View File

@@ -151,8 +151,7 @@ public static class Apple2
/// <param name="data">5and3 encoded data.</param>
public static byte[] Decode5and3(byte[] data)
{
if(data == null ||
data.Length != 410)
if(data is not { Length: 410 })
return null;
var buffer = new byte[data.Length];
@@ -189,8 +188,7 @@ public static class Apple2
/// <param name="data">6and2 encoded data.</param>
public static byte[] Decode6and2(byte[] data)
{
if(data == null ||
data.Length != 342)
if(data is not { Length: 342 })
return null;
var buffer = new byte[data.Length];

View File

@@ -47,8 +47,7 @@ public static class LisaTag
/// <returns>Decoded tag in Sony's format</returns>
public static SonyTag? DecodeSonyTag(byte[] tag)
{
if(tag == null ||
tag.Length != 12)
if(tag is not { Length: 12 })
return null;
var snTag = new SonyTag
@@ -74,8 +73,7 @@ public static class LisaTag
/// <returns>Decoded tag in Profile's format</returns>
public static ProfileTag? DecodeProfileTag(byte[] tag)
{
if(tag == null ||
tag.Length != 20)
if(tag is not { Length: 20 })
return null;
var phTag = new ProfileTag();
@@ -122,8 +120,7 @@ public static class LisaTag
/// <returns>Decoded tag in Priam's format</returns>
public static PriamTag? DecodePriamTag(byte[] tag)
{
if(tag == null ||
tag.Length != 24)
if(tag is not { Length: 24 })
return null;
var pmTag = new PriamTag();