From 27486121f299029b98fa6e9bf1f14bc79eb2a73f Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 18 Oct 2026 12:14:46 -0400 Subject: [PATCH] Make PhysicalMediaType a class instead of enum --- .../Data/ExtensionsTests.cs | 23 +- SabreTools.RedumpLib/Data/Enumerations.cs | 127 --------- SabreTools.RedumpLib/Data/Extensions.cs | 129 +++------ .../Data/PhysicalMediaType.cs | 252 ++++++++++++++++++ SabreTools.RedumpLib/Data/PhysicalSystem.cs | 4 +- SabreTools.RedumpLib/Tools/Formatter.cs | 83 +++--- 6 files changed, 346 insertions(+), 272 deletions(-) create mode 100644 SabreTools.RedumpLib/Data/PhysicalMediaType.cs diff --git a/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs b/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs index 73a880e..1e0e088 100644 --- a/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs +++ b/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs @@ -402,7 +402,6 @@ namespace SabreTools.RedumpLib.Test.Data /// private static readonly PhysicalMediaType?[] _mappablePhysicalMediaTypes = [ - PhysicalMediaType.NONE, PhysicalMediaType.BluRay, PhysicalMediaType.CDROM, PhysicalMediaType.DVD, @@ -423,7 +422,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GeneratePhysicalSystemMappingTestData))] public void MediaTypesTest(PhysicalSystem? physicalSystem) { - var actual = physicalSystem?.MediaTypes ?? [PhysicalMediaType.NONE]; + var actual = physicalSystem?.MediaTypes ?? [null]; Assert.NotEmpty(actual); } @@ -477,7 +476,9 @@ namespace SabreTools.RedumpLib.Test.Data var testData = new TheoryData() { { null, true } }; foreach (MediaType? discType in Enum.GetValues().Cast()) { - if (_mappableMediaTypes.Contains(discType)) + if (discType == MediaType.NONE) + testData.Add(discType, true); + else if (_mappableMediaTypes.Contains(discType)) testData.Add(discType, false); else testData.Add(discType, true); @@ -492,9 +493,9 @@ namespace SabreTools.RedumpLib.Test.Data /// MemberData-compatible list of MediaTypes public static TheoryData GeneratePhysicalMediaTypeMappingTestData() { - var testData = new TheoryData() { { null, true } }; + var testData = new TheoryData() { { null, false } }; - foreach (PhysicalMediaType? mediaType in Enum.GetValues().Cast()) + foreach (PhysicalMediaType? mediaType in PhysicalMediaType.AllMediaTypes) { if (_mappablePhysicalMediaTypes.Contains(mediaType)) testData.Add(mediaType, false); @@ -1130,7 +1131,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GeneratePhysicalMediaTypeTestData))] public void PhysicalMediaType_LongName(PhysicalMediaType? mediaType, bool expectNull) { - var actual = mediaType.LongName(); + var actual = mediaType?.Name; if (expectNull) Assert.Null(actual); @@ -1147,7 +1148,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GeneratePhysicalMediaTypeTestData))] public void PhysicalMediaType_ShortName(PhysicalMediaType? mediaType, bool expectNull) { - var actual = mediaType.ShortName(); + var actual = mediaType?.Code; if (expectNull) Assert.Null(actual); @@ -1164,7 +1165,7 @@ namespace SabreTools.RedumpLib.Test.Data [MemberData(nameof(GeneratePhysicalMediaTypeTestData))] public void PhysicalMediaType_ToPhysicalMediaType(PhysicalMediaType? mediaType, bool expectNone) { - string? longName = mediaType.LongName(); + string? longName = mediaType?.Name; string? longNameSpaceless = longName?.Replace(" ", string.Empty); var actualNormal = longName.ToPhysicalMediaType(); @@ -1172,8 +1173,8 @@ namespace SabreTools.RedumpLib.Test.Data if (expectNone) { - Assert.Equal(PhysicalMediaType.NONE, actualNormal); - Assert.Equal(PhysicalMediaType.NONE, actualSpaceless); + Assert.Null(actualNormal); + Assert.Null(actualSpaceless); } else { @@ -1189,7 +1190,7 @@ namespace SabreTools.RedumpLib.Test.Data public static TheoryData GeneratePhysicalMediaTypeTestData() { var testData = new TheoryData() { { null, true } }; - foreach (PhysicalMediaType? mediaType in Enum.GetValues().Cast()) + foreach (PhysicalMediaType? mediaType in PhysicalMediaType.AllMediaTypes) { testData.Add(mediaType, false); } diff --git a/SabreTools.RedumpLib/Data/Enumerations.cs b/SabreTools.RedumpLib/Data/Enumerations.cs index 1c6f91f..714d139 100644 --- a/SabreTools.RedumpLib/Data/Enumerations.cs +++ b/SabreTools.RedumpLib/Data/Enumerations.cs @@ -173,133 +173,6 @@ namespace SabreTools.RedumpLib.Data BiosDatfile = 4, } - /// - /// All possible media types not bound to specific site limitations - /// - public enum PhysicalMediaType - { - [HumanReadable(Available = false, LongName = "Unknown", ShortName = "unknown")] - NONE = 0, - - #region Punched Media - - [HumanReadable(Available = false, LongName = "Aperture card", ShortName = "aperture")] - ApertureCard = 1, - - [HumanReadable(Available = false, LongName = "Jacquard Loom card", ShortName = "jacquard loom card")] - JacquardLoomCard = 2, - - [HumanReadable(Available = false, LongName = "Magnetic stripe card", ShortName = "magnetic stripe")] - MagneticStripeCard = 3, - - [HumanReadable(Available = false, LongName = "Optical phonecard", ShortName = "optical phonecard")] - OpticalPhonecard = 4, - - [HumanReadable(Available = false, LongName = "Punched card", ShortName = "punchcard")] - PunchedCard = 5, - - [HumanReadable(Available = false, LongName = "Punched tape", ShortName = "punchtape")] - PunchedTape = 6, - - #endregion - - #region Tape - - [HumanReadable(Available = false, LongName = "Cassette Tape", ShortName = "cassette")] - Cassette = 7, - - [HumanReadable(Available = false, LongName = "Data Tape Cartridge", ShortName = "data cartridge")] - DataCartridge = 8, - - [HumanReadable(Available = false, LongName = "Open Reel Tape", ShortName = "open reel")] - OpenReel = 9, - - #endregion - - #region Disc / Disc - - [HumanReadable(LongName = "BD-ROM", ShortName = "bdrom")] - BluRay = 10, - - [HumanReadable(LongName = "CD-ROM", ShortName = "cdrom")] - CDROM = 11, - - [HumanReadable(LongName = "DVD-ROM", ShortName = "dvd")] - DVD = 12, - - [HumanReadable(LongName = "Floppy Disk", ShortName = "fd")] - FloppyDisk = 13, - - [HumanReadable(Available = false, LongName = "Floptical", ShortName = "floptical")] - Floptical = 14, - - [HumanReadable(LongName = "GD-ROM", ShortName = "gdrom")] - GDROM = 15, - - [HumanReadable(LongName = "HD-DVD-ROM", ShortName = "hddvd")] - HDDVD = 16, - - [HumanReadable(LongName = "Hard Disk", ShortName = "hdd")] - HardDisk = 17, - - [HumanReadable(Available = false, LongName = "Iomega Bernoulli Disk", ShortName = "bernoulli")] - IomegaBernoulliDisk = 18, - - [HumanReadable(Available = false, LongName = "Iomega Jaz", ShortName = "jaz")] - IomegaJaz = 19, - - [HumanReadable(Available = false, LongName = "Iomega Zip", ShortName = "zip")] - IomegaZip = 20, - - [HumanReadable(LongName = "LD-ROM / LV-ROM", ShortName = "ldrom")] - LaserDisc = 21, // LD-ROM and LV-ROM variants - - [HumanReadable(Available = false, LongName = "64DD Disk", ShortName = "64dd")] - Nintendo64DD = 22, - - [HumanReadable(Available = false, LongName = "Famicom Disk System Disk", ShortName = "fds")] - NintendoFamicomDiskSystem = 23, - - [HumanReadable(LongName = "GameCube Game Disc", ShortName = "gc")] - NintendoGameCubeGameDisc = 24, - - [HumanReadable(LongName = "Wii Optical Disc", ShortName = "wii")] - NintendoWiiOpticalDisc = 25, - - [HumanReadable(LongName = "Wii U Optical Disc", ShortName = "wiiu")] - NintendoWiiUOpticalDisc = 26, - - [HumanReadable(LongName = "UMD", ShortName = "umd")] - UMD = 27, - - [HumanReadable(LongName = "XGD", ShortName = "xgd")] - XGD = 34, - - #endregion - - #region Unsorted Formats - - [HumanReadable(Available = false, LongName = "Cartridge", ShortName = "cart")] - Cartridge = 28, - - [HumanReadable(Available = false, LongName = "CED", ShortName = "ced")] - CED = 29, - - [HumanReadable(Available = false, LongName = "Compact Flash", ShortName = "cf")] - CompactFlash = 30, - - [HumanReadable(Available = false, LongName = "MMC", ShortName = "mmc")] - MMC = 31, - - [HumanReadable(Available = false, LongName = "SD Card", ShortName = "sd")] - SDCard = 32, - - [HumanReadable(Available = false, LongName = "Flash Drive", ShortName = "fkd")] - FlashDrive = 33, - - #endregion - } - /// /// List of all recognized sort parameters /// diff --git a/SabreTools.RedumpLib/Data/Extensions.cs b/SabreTools.RedumpLib/Data/Extensions.cs index b8b3df9..20cdc00 100644 --- a/SabreTools.RedumpLib/Data/Extensions.cs +++ b/SabreTools.RedumpLib/Data/Extensions.cs @@ -142,48 +142,34 @@ namespace SabreTools.RedumpLib.Data /// DiscType if possible, null on error public static MediaType? ToMediaType(this PhysicalMediaType? mediaType) { - return mediaType switch - { - PhysicalMediaType.NONE => MediaType.NONE, - PhysicalMediaType.BluRay => MediaType.BD50, - PhysicalMediaType.CDROM => MediaType.CD, - PhysicalMediaType.DVD => MediaType.DVD9, - PhysicalMediaType.GDROM => MediaType.GDROM, - PhysicalMediaType.HDDVD => MediaType.HDDVDSL, - PhysicalMediaType.NintendoGameCubeGameDisc => MediaType.NintendoGameCubeGameDisc, - PhysicalMediaType.NintendoWiiOpticalDisc => MediaType.NintendoWiiOpticalDiscDL, - PhysicalMediaType.NintendoWiiUOpticalDisc => MediaType.NintendoWiiUOpticalDiscSL, - PhysicalMediaType.UMD => MediaType.UMDDL, - PhysicalMediaType.XGD => MediaType.XGD, + // Supported media types + if (mediaType == PhysicalMediaType.BluRay) + return MediaType.BD50; + else if (mediaType == PhysicalMediaType.CDROM) + return MediaType.CD; + else if (mediaType == PhysicalMediaType.DVD) + return MediaType.DVD9; + else if (mediaType == PhysicalMediaType.GDROM) + return MediaType.GDROM; + else if (mediaType == PhysicalMediaType.HDDVD) + return MediaType.HDDVDSL; + else if (mediaType == PhysicalMediaType.NintendoGameCubeGameDisc) + return MediaType.NintendoGameCubeGameDisc; + else if (mediaType == PhysicalMediaType.NintendoWiiOpticalDisc) + return MediaType.NintendoWiiOpticalDiscDL; + else if (mediaType == PhysicalMediaType.NintendoWiiUOpticalDisc) + return MediaType.NintendoWiiUOpticalDiscSL; + else if (mediaType == PhysicalMediaType.UMD) + return MediaType.UMDDL; + else if (mediaType == PhysicalMediaType.XGD) + return MediaType.XGD; - // Invalid cases for conversion - PhysicalMediaType.ApertureCard => null, - PhysicalMediaType.JacquardLoomCard => null, - PhysicalMediaType.MagneticStripeCard => null, - PhysicalMediaType.OpticalPhonecard => null, - PhysicalMediaType.PunchedCard => null, - PhysicalMediaType.PunchedTape => null, - PhysicalMediaType.Cassette => null, - PhysicalMediaType.DataCartridge => null, - PhysicalMediaType.OpenReel => null, - PhysicalMediaType.FloppyDisk => null, - PhysicalMediaType.Floptical => null, - PhysicalMediaType.HardDisk => null, - PhysicalMediaType.IomegaBernoulliDisk => null, - PhysicalMediaType.IomegaJaz => null, - PhysicalMediaType.IomegaZip => null, - PhysicalMediaType.LaserDisc => null, - PhysicalMediaType.Nintendo64DD => null, - PhysicalMediaType.NintendoFamicomDiskSystem => null, - PhysicalMediaType.Cartridge => null, - PhysicalMediaType.CED => null, - PhysicalMediaType.CompactFlash => null, - PhysicalMediaType.MMC => null, - PhysicalMediaType.SDCard => null, - PhysicalMediaType.FlashDrive => null, - null => null, - _ => null, - }; + // Special case for null + else if (mediaType is null) + return MediaType.NONE; + + // Everything else returns null + return null; } /// @@ -195,7 +181,7 @@ namespace SabreTools.RedumpLib.Data { return discType switch { - MediaType.NONE => PhysicalMediaType.NONE, + MediaType.NONE => null, MediaType.BD25 or MediaType.BD33 or MediaType.BD50 @@ -596,73 +582,36 @@ namespace SabreTools.RedumpLib.Data /// public static List ListMediaTypes() { - var mediaTypes = new List(); - - foreach (var val in Enum.GetValues(typeof(PhysicalMediaType))) - { - if (val is null || ((PhysicalMediaType)val) == PhysicalMediaType.NONE) - continue; - - mediaTypes.Add($"{((PhysicalMediaType?)val).ShortName()} - {((PhysicalMediaType?)val).LongName()}"); - } - - return mediaTypes; + var knownMediaTypes = Array.FindAll(PhysicalMediaType.AllMediaTypes, s => s.Available); + Array.Sort(knownMediaTypes, (x, y) => x.Name.CompareTo(y.Name)); + return [.. Array.ConvertAll(knownMediaTypes, val => $"{val.Code} - {val.Name}")]; } - /// - /// Get the longnames for each known media type - /// - public static string? LongName(this PhysicalMediaType mediaType) - => ((PhysicalMediaType?)mediaType).LongName(); - - /// - /// Get the longnames for each known media type - /// - /// - /// - public static string? LongName(this PhysicalMediaType? mediaType) - => AttributeHelper.GetHumanReadableAttribute(mediaType)?.LongName; - - /// - /// Get the shortnames for each known media type - /// - public static string? ShortName(this PhysicalMediaType mediaType) - => ((PhysicalMediaType?)mediaType).ShortName(); - - /// - /// Get the shortnames for each known media type - /// - /// - /// - public static string? ShortName(this PhysicalMediaType? mediaType) - => AttributeHelper.GetHumanReadableAttribute(mediaType)?.ShortName; - /// /// Get the PhysicalMediaType enum value for a given string /// /// String value to convert /// PhysicalMediaType represented by the string, if possible - public static PhysicalMediaType ToPhysicalMediaType(this string? mediaType) + public static PhysicalMediaType? ToPhysicalMediaType(this string? mediaType) { // No value means no match if (mediaType is null || mediaType.Length == 0) - return PhysicalMediaType.NONE; + return null; mediaType = mediaType.ToLowerInvariant(); - var mediaTypes = (PhysicalMediaType[])Enum.GetValues(typeof(PhysicalMediaType)); // Check short names - int index = Array.FindIndex(mediaTypes, s => mediaType == s.ShortName()?.ToLowerInvariant()); + int index = Array.FindIndex(PhysicalMediaType.AllMediaTypes, mt => mediaType == mt.Code?.ToLowerInvariant()); if (index > -1) - return mediaTypes[index]; + return PhysicalMediaType.AllMediaTypes[index]; // Check long names - index = Array.FindIndex(mediaTypes, s => mediaType == s.LongName()?.ToLowerInvariant() - || mediaType == s.LongName()?.Replace(" ", string.Empty)?.ToLowerInvariant()); + index = Array.FindIndex(PhysicalMediaType.AllMediaTypes, s => mediaType == s.Name.ToLowerInvariant() + || mediaType == s.Name.Replace(" ", string.Empty)?.ToLowerInvariant()); if (index > -1) - return mediaTypes[index]; + return PhysicalMediaType.AllMediaTypes[index]; - return PhysicalMediaType.NONE; + return null; } #endregion diff --git a/SabreTools.RedumpLib/Data/PhysicalMediaType.cs b/SabreTools.RedumpLib/Data/PhysicalMediaType.cs new file mode 100644 index 0000000..9e7c50a --- /dev/null +++ b/SabreTools.RedumpLib/Data/PhysicalMediaType.cs @@ -0,0 +1,252 @@ +namespace SabreTools.RedumpLib.Data +{ + /// + /// Represents a single physical media type + /// + public sealed class PhysicalMediaType + { + #region Properties + + /// + /// Human-readable name of the media type + /// + public readonly string Name; + + /// + /// Media type is included in the site + /// + public readonly bool Available; + + /// + /// Site short code, if it exists + /// + public readonly string? Code; + + #endregion + + #region Constructors + + /// + /// Constructor + /// + private PhysicalMediaType(string name, + bool available = true, + string? code = null) + { + Name = name; + + Available = available; + Code = code; + } + + #endregion + + #region Static Instances + + #region Punched Media + + public static readonly PhysicalMediaType ApertureCard = new("Aperture card", + available: false, + code: "aperture"); + + public static readonly PhysicalMediaType JacquardLoomCard = new("Jacquard Loom card", + available: false, + code: "jacquard loom card"); + + public static readonly PhysicalMediaType MagneticStripeCard = new("Magnetic stripe card", + available: false, + code: "magnetic stripe"); + + public static readonly PhysicalMediaType OpticalPhonecard = new("Optical phonecard", + available: false, + code: "optical phonecard"); + + public static readonly PhysicalMediaType PunchedCard = new("Punched card", + available: false, + code: "punchcard"); + + public static readonly PhysicalMediaType PunchedTape = new("Punched tape", + available: false, + code: "punchtape"); + + #endregion + + #region Tape + + public static readonly PhysicalMediaType Cassette = new("Cassette Tape", + available: false, + code: "cassette"); + + public static readonly PhysicalMediaType DataCartridge = new("Data Tape Cartridge", + available: false, + code: "data cartridge"); + + public static readonly PhysicalMediaType OpenReel = new("Open Reel Tape", + available: false, + code: "open reel"); + + #endregion + + #region Magnetic and Optical + + public static readonly PhysicalMediaType BluRay = new("BD-ROM", + code: "bdrom"); + + public static readonly PhysicalMediaType CDROM = new("CD-ROM", + code: "cdrom"); + + public static readonly PhysicalMediaType DVD = new("DVD-ROM", + code: "dvd"); + + public static readonly PhysicalMediaType FloppyDisk = new("Floppy Disk", + code: "fd"); + + public static readonly PhysicalMediaType Floptical = new("Floptical", + available: false, + code: "floptical"); + + public static readonly PhysicalMediaType GDROM = new("GD-ROM", + code: "gdrom"); + + public static readonly PhysicalMediaType HDDVD = new("HD-DVD-ROM", + code: "hddvd"); + + public static readonly PhysicalMediaType HardDisk = new("Hard Disk", + code: "hdd"); + + public static readonly PhysicalMediaType IomegaBernoulliDisk = new("Iomega Bernoulli Disk", + available: false, + code: "bernoulli"); + + public static readonly PhysicalMediaType IomegaJaz = new("Iomega Jaz", + available: false, + code: "jaz"); + + public static readonly PhysicalMediaType IomegaZip = new("Iomega Zip", + available: false, + code: "zip"); + + // LD-ROM and LV-ROM variants + public static readonly PhysicalMediaType LaserDisc = new("LD-ROM / LV-ROM", + code: "ldrom"); + + public static readonly PhysicalMediaType Nintendo64DD = new("64DD Disk", + available: false, + code: "64dd"); + + public static readonly PhysicalMediaType NintendoFamicomDiskSystem = new("Famicom Disk System Disk", + available: false, + code: "fds"); + + public static readonly PhysicalMediaType NintendoGameCubeGameDisc = new("GameCube Game Disc", + code: "gc"); + + public static readonly PhysicalMediaType NintendoWiiOpticalDisc = new("Wii Optical Disc", + code: "wii"); + + public static readonly PhysicalMediaType NintendoWiiUOpticalDisc = new("Wii U Optical Disc", + code: "wiiu"); + + public static readonly PhysicalMediaType UMD = new("UMD", + code: "umd"); + + public static readonly PhysicalMediaType XGD = new("Xbox Game Disc", + code: "xgd"); + + #endregion + + #region Unsorted Formats + + public static readonly PhysicalMediaType Cartridge = new("Cartridge", + available: false, + code: "cart"); + + public static readonly PhysicalMediaType CED = new("CED", + available: false, + code: "ced"); + + public static readonly PhysicalMediaType CompactFlash = new("Compact Flash", + available: false, + code: "cf"); + + public static readonly PhysicalMediaType MMC = new("MMC", + available: false, + code: "mmc"); + + public static readonly PhysicalMediaType SDCard = new("SD Card", + available: false, + code: "sd"); + + public static readonly PhysicalMediaType FlashDrive = new("Flash Drive", + available: false, + code: "fkd"); + + #endregion + + #endregion + + #region Static Collections + + /// + /// All media types + /// + public static readonly PhysicalMediaType[] AllMediaTypes = + [ + #region Punched Media + + ApertureCard, + JacquardLoomCard, + MagneticStripeCard, + OpticalPhonecard, + PunchedCard, + PunchedTape, + + #endregion + + #region Tape + + Cassette, + DataCartridge, + OpenReel, + + #endregion + + #region Magnetic and Optical + + BluRay, + CDROM, + DVD, + FloppyDisk, + Floptical, + GDROM, + HDDVD, + HardDisk, + IomegaBernoulliDisk, + IomegaJaz, + IomegaZip, + LaserDisc, + Nintendo64DD, + NintendoFamicomDiskSystem, + NintendoGameCubeGameDisc, + NintendoWiiOpticalDisc, + NintendoWiiUOpticalDisc, + UMD, + XGD, + + #endregion + + #region Unsorted Formats + + Cartridge, + CED, + CompactFlash, + MMC, + SDCard, + FlashDrive, + + #endregion + ]; + + #endregion + } +} diff --git a/SabreTools.RedumpLib/Data/PhysicalSystem.cs b/SabreTools.RedumpLib/Data/PhysicalSystem.cs index 915ba9f..5d1e2df 100644 --- a/SabreTools.RedumpLib/Data/PhysicalSystem.cs +++ b/SabreTools.RedumpLib/Data/PhysicalSystem.cs @@ -89,7 +89,7 @@ namespace SabreTools.RedumpLib.Data HasDat = hasDat; HasSbi = hasSbi; HasBios = hasBios; - MediaTypes = mediaTypes ?? [PhysicalMediaType.NONE]; + MediaTypes = mediaTypes ?? [null]; } #endregion @@ -1550,7 +1550,7 @@ namespace SabreTools.RedumpLib.Data #region Static Collections /// - /// All languages + /// All systems /// /// TODO: Figure out how to remove delimiters public static readonly PhysicalSystem[] AllSystems = diff --git a/SabreTools.RedumpLib/Tools/Formatter.cs b/SabreTools.RedumpLib/Tools/Formatter.cs index 6ae7bef..5c8b20c 100644 --- a/SabreTools.RedumpLib/Tools/Formatter.cs +++ b/SabreTools.RedumpLib/Tools/Formatter.cs @@ -330,7 +330,7 @@ namespace SabreTools.RedumpLib.Tools output.AppendLine("Ring Codes:"); // If we have a quad-layer disc or a generic media type case - if (discIdentifiers.Layerbreak3 != default || mediaType == PhysicalMediaType.NONE) + if (discIdentifiers.Layerbreak3 != default || mediaType == null) { AddIfExists(output, $"Layer 0 {Template.MasteringCodeField}", section.Layer0MasteringCode, 1); AddIfExists(output, $"Layer 0 {Template.MasteringSIDField}", section.Layer0MasteringSID, 1); @@ -622,49 +622,48 @@ namespace SabreTools.RedumpLib.Tools long? layerbreak2, long? layerbreak3) { -#pragma warning disable IDE0010 - switch (mediaType) + if (mediaType == PhysicalMediaType.DVD) { - case PhysicalMediaType.DVD: - if (layerbreak != default && layerbreak != default(long)) - return $"{mediaType.LongName()}-9"; - else - return $"{mediaType.LongName()}-5"; - - case PhysicalMediaType.BluRay: - if (layerbreak3 != default && layerbreak3 != default(long)) - return $"{mediaType.LongName()}-128"; - else if (layerbreak2 != default && layerbreak2 != default(long)) - return $"{mediaType.LongName()}-100"; - else if (layerbreak != default && layerbreak != default(long) && picIdentifier == "BDU") - return $"{mediaType.LongName()}-66"; - else if (layerbreak != default && layerbreak != default(long) && size > 53_687_063_712) - return $"{mediaType.LongName()}-66"; - else if (layerbreak != default && layerbreak != default(long)) - return $"{mediaType.LongName()}-50"; - else if (picIdentifier == "BDU") - return $"{mediaType.LongName()}-33"; - else if (size > 26_843_531_856) - return $"{mediaType.LongName()}-33"; - else - return $"{mediaType.LongName()}-25"; - - case PhysicalMediaType.HDDVD: - if (layerbreak != default && layerbreak != default(long)) - return $"{mediaType.LongName()}-DL"; - else - return $"{mediaType.LongName()}-SL"; - - case PhysicalMediaType.UMD: - if (layerbreak != default && layerbreak != default(long)) - return $"{mediaType.LongName()}-DL"; - else - return $"{mediaType.LongName()}-SL"; - - default: - return mediaType.LongName(); + if (layerbreak != default && layerbreak != default(long)) + return $"{mediaType.Name}-9"; + else + return $"{mediaType.Name}-5"; } -#pragma warning restore IDE0010 + else if (mediaType == PhysicalMediaType.BluRay) + { + if (layerbreak3 != default && layerbreak3 != default(long)) + return $"{mediaType.Name}-128"; + else if (layerbreak2 != default && layerbreak2 != default(long)) + return $"{mediaType.Name}-100"; + else if (layerbreak != default && layerbreak != default(long) && picIdentifier == "BDU") + return $"{mediaType.Name}-66"; + else if (layerbreak != default && layerbreak != default(long) && size > 53_687_063_712) + return $"{mediaType.Name}-66"; + else if (layerbreak != default && layerbreak != default(long)) + return $"{mediaType.Name}-50"; + else if (picIdentifier == "BDU") + return $"{mediaType.Name}-33"; + else if (size > 26_843_531_856) + return $"{mediaType.Name}-33"; + else + return $"{mediaType.Name}-25"; + } + else if (mediaType == PhysicalMediaType.HDDVD) + { + if (layerbreak != default && layerbreak != default(long)) + return $"{mediaType.Name}-DL"; + else + return $"{mediaType.Name}-SL"; + } + else if (mediaType == PhysicalMediaType.UMD) + { + if (layerbreak != default && layerbreak != default(long)) + return $"{mediaType.Name}-DL"; + else + return $"{mediaType.Name}-SL"; + } + + return mediaType?.Name; } ///