diff --git a/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs b/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs index 92db1b1..7a799bd 100644 --- a/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs +++ b/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs @@ -272,6 +272,113 @@ namespace SabreTools.RedumpLib.Test.Data #endregion + #region Pack Type + + /// + /// Check that every PackType has a long name provided + /// + /// PackType value to check + /// True to expect a null value, false otherwise + [Theory] + [MemberData(nameof(GeneratePackTypeTestData))] + public void PackType_LongName(PackType? packType, bool expectNull) + { + var actual = packType.LongName(); + + if (expectNull) + Assert.Null(actual); + else + Assert.NotNull(actual); + } + + /// + /// Check that every PackType has a short name provided + /// + /// PackType value to check + /// True to expect a null value, false otherwise + [Theory] + [MemberData(nameof(GeneratePackTypeTestData))] + public void PackType_ShortName(PackType? packType, bool expectNull) + { + var actual = packType.ShortName(); + + if (expectNull) + Assert.Null(actual); + else + Assert.NotNull(actual); + } + + /// + /// Ensure that every PackType that has a short name that is unique + /// + [Fact] + public void PackType_ShortName_NoDuplicates() + { + var fullPackTypes = Enum.GetValues().Cast().ToList(); + var filteredPackTypes = new Dictionary(); + + int totalCount = 0; + foreach (PackType? packType in fullPackTypes) + { + var code = packType.ShortName(); + if (string.IsNullOrEmpty(code)) + continue; + + // Throw if the code already exists + if (filteredPackTypes.ContainsKey(code)) + throw new DuplicateNameException($"Code {code} already in dictionary"); + + filteredPackTypes[code] = packType; + totalCount++; + } + + Assert.Equal(totalCount, filteredPackTypes.Count); + } + + /// + /// Check that every PackType can be mapped from a string + /// + /// PackType value to check + /// True to expect a null value, false otherwise + [Theory] + [MemberData(nameof(GeneratePackTypeTestData))] + public void PackType_ToPackType(PackType? packType, bool expectNull) + { + string? longName = packType.LongName(); + string? longNameSpaceless = longName?.Replace(" ", string.Empty); + + var actualNormal = longName.ToPackType(); + var actualSpaceless = longNameSpaceless.ToPackType(); + + if (expectNull) + { + Assert.Null(actualNormal); + Assert.Null(actualSpaceless); + } + else + { + Assert.Equal(packType, actualNormal); + Assert.Equal(packType, actualSpaceless); + } + } + + /// + /// Generate a test set of PackType values + /// + /// MemberData-compatible list of PackType values + public static TheoryData GeneratePackTypeTestData() + { + var testData = new TheoryData() { { null, true } }; + foreach (PackType? packType in Enum.GetValues().Cast()) + { + testData.Add(packType, false); + } + + return testData; + } + + #endregion + #region Physical Media Type [Fact] diff --git a/SabreTools.RedumpLib.Test/RedumpInfo/ExtensionsTests.cs b/SabreTools.RedumpLib.Test/RedumpInfo/ExtensionsTests.cs index 810b290..d2211d8 100644 --- a/SabreTools.RedumpLib.Test/RedumpInfo/ExtensionsTests.cs +++ b/SabreTools.RedumpLib.Test/RedumpInfo/ExtensionsTests.cs @@ -420,113 +420,6 @@ namespace SabreTools.RedumpLib.Test.RedumpInfo #endregion - #region Pack Type - - /// - /// Check that every PackType has a long name provided - /// - /// PackType value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GeneratePackTypeTestData))] - public void PackType_LongName(PackType? packType, bool expectNull) - { - var actual = packType.LongName(); - - if (expectNull) - Assert.Null(actual); - else - Assert.NotNull(actual); - } - - /// - /// Check that every PackType has a short name provided - /// - /// PackType value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GeneratePackTypeTestData))] - public void PackType_ShortName(PackType? packType, bool expectNull) - { - var actual = packType.ShortName(); - - if (expectNull) - Assert.Null(actual); - else - Assert.NotNull(actual); - } - - /// - /// Ensure that every PackType that has a short name that is unique - /// - [Fact] - public void PackType_ShortName_NoDuplicates() - { - var fullPackTypes = Enum.GetValues().Cast().ToList(); - var filteredPackTypes = new Dictionary(); - - int totalCount = 0; - foreach (PackType? packType in fullPackTypes) - { - var code = packType.ShortName(); - if (string.IsNullOrEmpty(code)) - continue; - - // Throw if the code already exists - if (filteredPackTypes.ContainsKey(code)) - throw new DuplicateNameException($"Code {code} already in dictionary"); - - filteredPackTypes[code] = packType; - totalCount++; - } - - Assert.Equal(totalCount, filteredPackTypes.Count); - } - - /// - /// Check that every PackType can be mapped from a string - /// - /// PackType value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GeneratePackTypeTestData))] - public void PackType_ToPackType(PackType? packType, bool expectNull) - { - string? longName = packType.LongName(); - string? longNameSpaceless = longName?.Replace(" ", string.Empty); - - var actualNormal = longName.ToPackType(); - var actualSpaceless = longNameSpaceless.ToPackType(); - - if (expectNull) - { - Assert.Null(actualNormal); - Assert.Null(actualSpaceless); - } - else - { - Assert.Equal(packType, actualNormal); - Assert.Equal(packType, actualSpaceless); - } - } - - /// - /// Generate a test set of PackType values - /// - /// MemberData-compatible list of PackType values - public static TheoryData GeneratePackTypeTestData() - { - var testData = new TheoryData() { { null, true } }; - foreach (PackType? packType in Enum.GetValues().Cast()) - { - testData.Add(packType, false); - } - - return testData; - } - - #endregion - #region System Category /// diff --git a/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs b/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs index a98f68d..b30c075 100644 --- a/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs +++ b/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs @@ -467,113 +467,6 @@ namespace SabreTools.RedumpLib.Test.RedumpOrg #endregion - #region Pack Type - - /// - /// Check that every PackType has a long name provided - /// - /// PackType value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GeneratePackTypeTestData))] - public void PackType_LongName(PackType? packType, bool expectNull) - { - var actual = packType.LongName(); - - if (expectNull) - Assert.Null(actual); - else - Assert.NotNull(actual); - } - - /// - /// Check that every PackType has a short name provided - /// - /// PackType value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GeneratePackTypeTestData))] - public void PackType_ShortName(PackType? packType, bool expectNull) - { - var actual = packType.ShortName(); - - if (expectNull) - Assert.Null(actual); - else - Assert.NotNull(actual); - } - - /// - /// Ensure that every PackType that has a short name that is unique - /// - [Fact] - public void PackType_ShortName_NoDuplicates() - { - var fullPackTypes = Enum.GetValues().Cast().ToList(); - var filteredPackTypes = new Dictionary(); - - int totalCount = 0; - foreach (PackType? packType in fullPackTypes) - { - var code = packType.ShortName(); - if (string.IsNullOrEmpty(code)) - continue; - - // Throw if the code already exists - if (filteredPackTypes.ContainsKey(code)) - throw new DuplicateNameException($"Code {code} already in dictionary"); - - filteredPackTypes[code] = packType; - totalCount++; - } - - Assert.Equal(totalCount, filteredPackTypes.Count); - } - - /// - /// Check that every PackType can be mapped from a string - /// - /// PackType value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GeneratePackTypeTestData))] - public void PackType_ToPackType(PackType? packType, bool expectNull) - { - string? longName = packType.LongName(); - string? longNameSpaceless = longName?.Replace(" ", string.Empty); - - var actualNormal = longName.ToPackType(); - var actualSpaceless = longNameSpaceless.ToPackType(); - - if (expectNull) - { - Assert.Null(actualNormal); - Assert.Null(actualSpaceless); - } - else - { - Assert.Equal(packType, actualNormal); - Assert.Equal(packType, actualSpaceless); - } - } - - /// - /// Generate a test set of PackType values - /// - /// MemberData-compatible list of PackType values - public static TheoryData GeneratePackTypeTestData() - { - var testData = new TheoryData() { { null, true } }; - foreach (PackType? packType in Enum.GetValues().Cast()) - { - testData.Add(packType, false); - } - - return testData; - } - - #endregion - #region Site Code /// diff --git a/SabreTools.RedumpLib/Data/Enumerations.cs b/SabreTools.RedumpLib/Data/Enumerations.cs index 3e19692..4f74427 100644 --- a/SabreTools.RedumpLib/Data/Enumerations.cs +++ b/SabreTools.RedumpLib/Data/Enumerations.cs @@ -1670,6 +1670,36 @@ namespace SabreTools.RedumpLib.Data #endregion } + /// + /// All possible packs + /// + public enum PackType + { + [HumanReadable(LongName = "CUES", ShortName = "cues")] + Cuesheets, + + [HumanReadable(LongName = "DAT", ShortName = "datfile")] + Datfile, + + /// Only in redump.org + [HumanReadable(LongName = "Decrypted KEYS", ShortName = "dkeys")] + DecryptedKeys, + + /// Only in redump.org + [HumanReadable(LongName = "GDIs", ShortName = "gdi")] + Gdis, + + [HumanReadable(LongName = "KEYS", ShortName = "keys")] + Keys, + + /// Only in redump.org + [HumanReadable(LongName = "LSD", ShortName = "lsd")] + Lsds, + + [HumanReadable(LongName = "SBI", ShortName = "sbi")] + Sbis, + } + /// /// All possible media types not bound to specific site limitations /// diff --git a/SabreTools.RedumpLib/Data/Extensions.cs b/SabreTools.RedumpLib/Data/Extensions.cs index be784f1..c4ac1f0 100644 --- a/SabreTools.RedumpLib/Data/Extensions.cs +++ b/SabreTools.RedumpLib/Data/Extensions.cs @@ -967,6 +967,70 @@ namespace SabreTools.RedumpLib.Data #endregion + #region Pack Type + + /// + /// Get the human readable name for a PackType + /// + /// + /// + public static string? LongName(this PackType packType) + => AttributeHelper.GetHumanReadableAttribute(packType)?.LongName; + + /// + /// Get the human readable name for a PackType + /// + /// + /// + public static string? LongName(this PackType? packType) + => AttributeHelper.GetHumanReadableAttribute(packType)?.LongName; + + /// + /// Get the URL path part for a PackType + /// + /// + /// + public static string? ShortName(this PackType packType) + => AttributeHelper.GetHumanReadableAttribute(packType)?.ShortName; + + /// + /// Get the URL path part for a PackType + /// + /// + /// + public static string? ShortName(this PackType? packType) + => AttributeHelper.GetHumanReadableAttribute(packType)?.ShortName; + + /// + /// Get the Region enum value for a given string + /// + /// String value to convert + /// Region represented by the string, if possible + public static PackType? ToPackType(this string? packType) + { + // No value means no match + if (packType is null || packType.Length == 0) + return null; + + packType = packType.ToLowerInvariant(); + var packTypes = (PackType[])Enum.GetValues(typeof(PackType)); + + // Check short names + int index = Array.FindIndex(packTypes, s => packType == s.ShortName()?.ToLowerInvariant()); + if (index > -1) + return packTypes[index]; + + // Check long names + index = Array.FindIndex(packTypes, s => packType == s.LongName()?.ToLowerInvariant() + || packType == s.LongName()?.Replace(" ", string.Empty)?.ToLowerInvariant()); + if (index > -1) + return packTypes[index]; + + return null; + } + + #endregion + #region Physical Media Type /// diff --git a/SabreTools.RedumpLib/RedumpInfo/Client.cs b/SabreTools.RedumpLib/RedumpInfo/Client.cs index 5e44982..f1384f6 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Client.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Client.cs @@ -1422,7 +1422,10 @@ namespace SabreTools.RedumpLib.RedumpInfo { PackType.Cuesheets => system.HasCues(), PackType.Datfile => system.HasDat(), + PackType.DecryptedKeys => false, + PackType.Gdis => false, PackType.Keys => system.HasKeys(), + PackType.Lsds => false, PackType.Sbis => system.HasSbi(), _ => false, }; diff --git a/SabreTools.RedumpLib/RedumpInfo/Data/Enumerations.cs b/SabreTools.RedumpLib/RedumpInfo/Data/Enumerations.cs index 66b270f..ef598a7 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Data/Enumerations.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Data/Enumerations.cs @@ -100,22 +100,4 @@ namespace SabreTools.RedumpLib.RedumpInfo.Data [HumanReadable(LongName = "Wii U Optical Disc (SL)", ShortName = "bd25wiiu")] WiiUOpticalDiscSL, } - - /// - /// All possible packs - /// - public enum PackType - { - [HumanReadable(LongName = "CUES", ShortName = "cues")] - Cuesheets, - - [HumanReadable(LongName = "DAT", ShortName = "datfile")] - Datfile, - - [HumanReadable(LongName = "KEYS", ShortName = "keys")] - Keys, - - [HumanReadable(LongName = "SBI", ShortName = "sbi")] - Sbis, - } } diff --git a/SabreTools.RedumpLib/RedumpInfo/Data/Extensions.cs b/SabreTools.RedumpLib/RedumpInfo/Data/Extensions.cs index fd78b18..e8128a5 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Data/Extensions.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Data/Extensions.cs @@ -324,70 +324,6 @@ namespace SabreTools.RedumpLib.RedumpInfo.Data #endregion - #region Pack Type - - /// - /// Get the human readable name for a PackType - /// - /// - /// - public static string? LongName(this PackType packType) - => AttributeHelper.GetHumanReadableAttribute(packType)?.LongName; - - /// - /// Get the human readable name for a PackType - /// - /// - /// - public static string? LongName(this PackType? packType) - => AttributeHelper.GetHumanReadableAttribute(packType)?.LongName; - - /// - /// Get the URL path part for a PackType - /// - /// - /// - public static string? ShortName(this PackType packType) - => AttributeHelper.GetHumanReadableAttribute(packType)?.ShortName; - - /// - /// Get the URL path part for a PackType - /// - /// - /// - public static string? ShortName(this PackType? packType) - => AttributeHelper.GetHumanReadableAttribute(packType)?.ShortName; - - /// - /// Get the Region enum value for a given string - /// - /// String value to convert - /// Region represented by the string, if possible - public static PackType? ToPackType(this string? packType) - { - // No value means no match - if (packType is null || packType.Length == 0) - return null; - - packType = packType.ToLowerInvariant(); - var packTypes = (PackType[])Enum.GetValues(typeof(PackType)); - - // Check short names - int index = Array.FindIndex(packTypes, s => packType == s.ShortName()?.ToLowerInvariant()); - if (index > -1) - return packTypes[index]; - - // Check long names - index = Array.FindIndex(packTypes, s => packType == s.LongName()?.ToLowerInvariant() - || packType == s.LongName()?.Replace(" ", string.Empty)?.ToLowerInvariant()); - if (index > -1) - return packTypes[index]; - - return null; - } - - #endregion - #region System Category /// diff --git a/SabreTools.RedumpLib/RedumpInfo/Packs.cs b/SabreTools.RedumpLib/RedumpInfo/Packs.cs index 5c41536..963b7c7 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Packs.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Packs.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using SabreTools.RedumpLib.Data; -using SabreTools.RedumpLib.RedumpInfo.Data; namespace SabreTools.RedumpLib.RedumpInfo { diff --git a/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs b/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs index f48a7c8..a5b1742 100644 --- a/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs +++ b/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs @@ -260,7 +260,10 @@ namespace SabreTools.RedumpLib.RedumpInfo { case PackType.Cuesheets: sb.AppendFormat(CuesPath, systemName); break; case PackType.Datfile: sb.AppendFormat(DatfilePath, systemName); break; + case PackType.DecryptedKeys: break; // Not supported + case PackType.Gdis: break; // Not supported case PackType.Keys: sb.AppendFormat(KeysPath, systemName); break; + case PackType.Lsds: break; // Not supported case PackType.Sbis: sb.AppendFormat(SbiPath, systemName); break; default: throw new ArgumentOutOfRangeException(nameof(packType)); diff --git a/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs b/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs index 4be8e2b..b650aad 100644 --- a/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs +++ b/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs @@ -148,33 +148,6 @@ namespace SabreTools.RedumpLib.RedumpOrg.Data OptionsMenu, } - /// - /// All possible packs - /// - public enum PackType - { - [HumanReadable(LongName = "CUES", ShortName = "cues")] - Cuesheets, - - [HumanReadable(LongName = "DAT", ShortName = "datfile")] - Datfile, - - [HumanReadable(LongName = "Decrypted KEYS", ShortName = "dkeys")] - DecryptedKeys, - - [HumanReadable(LongName = "GDIs", ShortName = "gdi")] - Gdis, - - [HumanReadable(LongName = "KEYS", ShortName = "keys")] - Keys, - - [HumanReadable(LongName = "LSD", ShortName = "lsd")] - Lsds, - - [HumanReadable(LongName = "SBI", ShortName = "sbi")] - Sbis, - } - /// /// List of all Redump site codes /// diff --git a/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs b/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs index ecd1e37..1d0465f 100644 --- a/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs +++ b/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs @@ -312,70 +312,6 @@ namespace SabreTools.RedumpLib.RedumpOrg.Data #endregion - #region Pack Type - - /// - /// Get the human readable name for a PackType - /// - /// - /// - public static string? LongName(this PackType packType) - => AttributeHelper.GetHumanReadableAttribute(packType)?.LongName; - - /// - /// Get the human readable name for a PackType - /// - /// - /// - public static string? LongName(this PackType? packType) - => AttributeHelper.GetHumanReadableAttribute(packType)?.LongName; - - /// - /// Get the URL path part for a PackType - /// - /// - /// - public static string? ShortName(this PackType packType) - => AttributeHelper.GetHumanReadableAttribute(packType)?.ShortName; - - /// - /// Get the URL path part for a PackType - /// - /// - /// - public static string? ShortName(this PackType? packType) - => AttributeHelper.GetHumanReadableAttribute(packType)?.ShortName; - - /// - /// Get the Region enum value for a given string - /// - /// String value to convert - /// Region represented by the string, if possible - public static PackType? ToPackType(this string? packType) - { - // No value means no match - if (packType is null || packType.Length == 0) - return null; - - packType = packType.ToLowerInvariant(); - var packTypes = (PackType[])Enum.GetValues(typeof(PackType)); - - // Check short names - int index = Array.FindIndex(packTypes, s => packType == s.ShortName()?.ToLowerInvariant()); - if (index > -1) - return packTypes[index]; - - // Check long names - index = Array.FindIndex(packTypes, s => packType == s.LongName()?.ToLowerInvariant() - || packType == s.LongName()?.Replace(" ", string.Empty)?.ToLowerInvariant()); - if (index > -1) - return packTypes[index]; - - return null; - } - - #endregion - #region Site Code /// diff --git a/SabreTools.RedumpLib/RedumpOrg/Packs.cs b/SabreTools.RedumpLib/RedumpOrg/Packs.cs index 0611415..c7b33de 100644 --- a/SabreTools.RedumpLib/RedumpOrg/Packs.cs +++ b/SabreTools.RedumpLib/RedumpOrg/Packs.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using SabreTools.RedumpLib.Data; -using SabreTools.RedumpLib.RedumpOrg.Data; namespace SabreTools.RedumpLib.RedumpOrg {