diff --git a/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs b/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs index 5126d9a..512bc97 100644 --- a/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs +++ b/SabreTools.RedumpLib.Test/Data/ExtensionsTests.cs @@ -237,5 +237,157 @@ namespace SabreTools.RedumpLib.Test.Data } #endregion + + #region Region + + /// + /// Check that every Region has a long name provided + /// + /// Region value to check + /// True to expect a null value, false otherwise + [Theory] + [MemberData(nameof(GenerateRegionTestData))] + public void Region_LongName(Region? region, bool expectNull) + { + var actual = region.LongName(); + + if (expectNull) + Assert.Null(actual); + else + Assert.NotNull(actual); + } + + /// + /// Check that every Region has a short name provided + /// + /// Region value to check + /// True to expect a null value, false otherwise + [Theory] + [MemberData(nameof(GenerateRegionTestData))] + public void Region_ShortName(Region? region, bool expectNull) + { + var actual = region.ShortName(); + + if (expectNull) + Assert.Null(actual); + else + Assert.NotNull(actual); + } + + /// + /// Ensure that every Region that has a short name that is unique + /// + [Fact] + public void Region_ShortName_NoDuplicates() + { + var fullRegions = Enum.GetValues().Cast().ToList(); + var filteredRegions = new Dictionary(); + + int totalCount = 0; + foreach (Region? region in fullRegions) + { + var code = region.ShortName(); + if (string.IsNullOrEmpty(code)) + continue; + + // Throw if the code already exists + if (filteredRegions.ContainsKey(code)) + throw new DuplicateNameException($"Code {code} already in dictionary"); + + filteredRegions[code] = region; + totalCount++; + } + + Assert.Equal(totalCount, filteredRegions.Count); + } + + /// + /// Check that every Region has a short name provided + /// + /// Region value to check + /// True to expect a null value, false otherwise + [Theory] + [MemberData(nameof(GenerateRegionTestData))] + public void Region_ShortNameAlt(Region? region, bool expectNull) + { + var actual = region.ShortNameAlt(); + + if (expectNull) + Assert.Null(actual); + else + Assert.NotNull(actual); + } + + /// + /// Ensure that every Region that has a short name that is unique + /// + [Fact] + public void Region_ShortNameAlt_NoDuplicates() + { + var fullRegions = Enum.GetValues().Cast().ToList(); + var filteredRegions = new Dictionary(); + + int totalCount = 0; + foreach (Region? region in fullRegions) + { + var code = region.ShortNameAlt(); + if (string.IsNullOrEmpty(code)) + continue; + + // Throw if the code already exists + if (filteredRegions.ContainsKey(code)) + throw new DuplicateNameException($"Code {code} already in dictionary"); + + filteredRegions[code] = region; + totalCount++; + } + + Assert.Equal(totalCount, filteredRegions.Count); + } + + /// + /// Check that every Region can be mapped from a string + /// + /// Region value to check + /// True to expect a null value, false otherwise + [Theory] + [MemberData(nameof(GenerateRegionTestData))] + public void Region_ToRegion(Region? region, bool expectNull) + { + string? longName = region.LongName(); + string? longNameSpaceless = longName?.Replace(" ", string.Empty); + + var actualNormal = longName.ToRegion(); + var actualSpaceless = longNameSpaceless.ToRegion(); + + if (expectNull) + { + Assert.Null(actualNormal); + Assert.Null(actualSpaceless); + } + else + { + Assert.Equal(region, actualNormal); + Assert.Equal(region, actualSpaceless); + } + } + + /// + /// Generate a test set of Region values + /// + /// MemberData-compatible list of Region values + public static TheoryData GenerateRegionTestData() + { + var testData = new TheoryData() { { null, true } }; + foreach (Region? region in Enum.GetValues().Cast()) + { + testData.Add(region, false); + } + + return testData; + } + + #endregion + } } diff --git a/SabreTools.RedumpLib.Test/RedumpInfo/ExtensionsTests.cs b/SabreTools.RedumpLib.Test/RedumpInfo/ExtensionsTests.cs index 2562974..326bec8 100644 --- a/SabreTools.RedumpLib.Test/RedumpInfo/ExtensionsTests.cs +++ b/SabreTools.RedumpLib.Test/RedumpInfo/ExtensionsTests.cs @@ -617,113 +617,6 @@ namespace SabreTools.RedumpLib.Test.RedumpInfo #endregion - #region Region - - /// - /// Check that every Region has a long name provided - /// - /// Region value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GenerateRegionTestData))] - public void Region_LongName(Region? region, bool expectNull) - { - var actual = region.LongName(); - - if (expectNull) - Assert.Null(actual); - else - Assert.NotNull(actual); - } - - /// - /// Check that every Region has a short name provided - /// - /// Region value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GenerateRegionTestData))] - public void Region_ShortName(Region? region, bool expectNull) - { - var actual = region.ShortName(); - - if (expectNull) - Assert.Null(actual); - else - Assert.NotNull(actual); - } - - /// - /// Ensure that every Region that has a short name that is unique - /// - [Fact] - public void Region_ShortName_NoDuplicates() - { - var fullRegions = Enum.GetValues().Cast().ToList(); - var filteredRegions = new Dictionary(); - - int totalCount = 0; - foreach (Region? region in fullRegions) - { - var code = region.ShortName(); - if (string.IsNullOrEmpty(code)) - continue; - - // Throw if the code already exists - if (filteredRegions.ContainsKey(code)) - throw new DuplicateNameException($"Code {code} already in dictionary"); - - filteredRegions[code] = region; - totalCount++; - } - - Assert.Equal(totalCount, filteredRegions.Count); - } - - /// - /// Check that every Region can be mapped from a string - /// - /// Region value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GenerateRegionTestData))] - public void Region_ToRegion(Region? region, bool expectNull) - { - string? longName = region.LongName(); - string? longNameSpaceless = longName?.Replace(" ", string.Empty); - - var actualNormal = longName.ToRegion(); - var actualSpaceless = longNameSpaceless.ToRegion(); - - if (expectNull) - { - Assert.Null(actualNormal); - Assert.Null(actualSpaceless); - } - else - { - Assert.Equal(region, actualNormal); - Assert.Equal(region, actualSpaceless); - } - } - - /// - /// Generate a test set of Region values - /// - /// MemberData-compatible list of Region values - public static TheoryData GenerateRegionTestData() - { - var testData = new TheoryData() { { null, true } }; - foreach (Region? region in Enum.GetValues().Cast()) - { - testData.Add(region, false); - } - - return testData; - } - - #endregion - #region System /// diff --git a/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs b/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs index 18c16e3..99917d1 100644 --- a/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs +++ b/SabreTools.RedumpLib.Test/RedumpOrg/ExtensionsTests.cs @@ -664,113 +664,6 @@ namespace SabreTools.RedumpLib.Test.RedumpOrg #endregion - #region Region - - /// - /// Check that every Region has a long name provided - /// - /// Region value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GenerateRegionTestData))] - public void Region_LongName(Region? region, bool expectNull) - { - var actual = region.LongName(); - - if (expectNull) - Assert.Null(actual); - else - Assert.NotNull(actual); - } - - /// - /// Check that every Region has a short name provided - /// - /// Region value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GenerateRegionTestData))] - public void Region_ShortName(Region? region, bool expectNull) - { - var actual = region.ShortName(); - - if (expectNull) - Assert.Null(actual); - else - Assert.NotNull(actual); - } - - /// - /// Ensure that every Region that has a short name that is unique - /// - [Fact] - public void Region_ShortName_NoDuplicates() - { - var fullRegions = Enum.GetValues().Cast().ToList(); - var filteredRegions = new Dictionary(); - - int totalCount = 0; - foreach (Region? region in fullRegions) - { - var code = region.ShortName(); - if (string.IsNullOrEmpty(code)) - continue; - - // Throw if the code already exists - if (filteredRegions.ContainsKey(code)) - throw new DuplicateNameException($"Code {code} already in dictionary"); - - filteredRegions[code] = region; - totalCount++; - } - - Assert.Equal(totalCount, filteredRegions.Count); - } - - /// - /// Check that every Region can be mapped from a string - /// - /// Region value to check - /// True to expect a null value, false otherwise - [Theory] - [MemberData(nameof(GenerateRegionTestData))] - public void Region_ToRegion(Region? region, bool expectNull) - { - string? longName = region.LongName(); - string? longNameSpaceless = longName?.Replace(" ", string.Empty); - - var actualNormal = longName.ToRegion(); - var actualSpaceless = longNameSpaceless.ToRegion(); - - if (expectNull) - { - Assert.Null(actualNormal); - Assert.Null(actualSpaceless); - } - else - { - Assert.Equal(region, actualNormal); - Assert.Equal(region, actualSpaceless); - } - } - - /// - /// Generate a test set of Region values - /// - /// MemberData-compatible list of Region values - public static TheoryData GenerateRegionTestData() - { - var testData = new TheoryData() { { null, true } }; - foreach (Region? region in Enum.GetValues().Cast()) - { - testData.Add(region, false); - } - - return testData; - } - - #endregion - #region Site Code /// diff --git a/SabreTools.RedumpLib/Attributes/RegionCodeAttribute.cs b/SabreTools.RedumpLib/Attributes/RegionCodeAttribute.cs new file mode 100644 index 0000000..c7646a7 --- /dev/null +++ b/SabreTools.RedumpLib/Attributes/RegionCodeAttribute.cs @@ -0,0 +1,13 @@ +namespace SabreTools.RedumpLib.Attributes +{ + /// + /// Attribute specifc to Region values + /// + public class RegionCodeAttribute : HumanReadableAttribute + { + /// + /// redump.org short code + /// + public string? RedumpOrgCode { get; set; } + } +} diff --git a/SabreTools.RedumpLib/Data/Enumerations.cs b/SabreTools.RedumpLib/Data/Enumerations.cs index 6202f2e..0983be7 100644 --- a/SabreTools.RedumpLib/Data/Enumerations.cs +++ b/SabreTools.RedumpLib/Data/Enumerations.cs @@ -1754,4 +1754,1024 @@ namespace SabreTools.RedumpLib.Data #endregion } + + /// + /// List of all known regions + /// + /// + /// https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + /// + public enum Region + { + #region Aggregate Regions + + [RegionCode(LongName = "Asia", ShortName = "xa", RedumpOrgCode = "A")] + Asia, + + [RegionCode(LongName = "Europe", ShortName = "eu", RedumpOrgCode = "E")] + Europe, + + [RegionCode(LongName = "Export", ShortName = "xp", RedumpOrgCode = "Ex")] + Export, + + [RegionCode(LongName = "Latin America", ShortName = "xl", RedumpOrgCode = "LAm")] + LatinAmerica, + + [RegionCode(LongName = "Scandinavia", ShortName = "xs", RedumpOrgCode = "Sca")] + Scandinavia, + + [RegionCode(LongName = "World", ShortName = "un", RedumpOrgCode = "W")] + World, + + #endregion + + #region Aggregate Regions - redump.org Only + + [RegionCode(LongName = "Asia, Europe", RedumpOrgCode = "A,E")] + AsiaEurope, + + [RegionCode(LongName = "Asia, USA", RedumpOrgCode = "A,U")] + AsiaUSA, + + [RegionCode(LongName = "Australia, Germany", RedumpOrgCode = "Au,G")] + AustraliaGermany, + + [RegionCode(LongName = "Australia, New Zealand", RedumpOrgCode = "Au,Nz")] + AustraliaNewZealand, + + [RegionCode(LongName = "Austria, Switzerland", RedumpOrgCode = "At,Ch")] + AustriaSwitzerland, + + [RegionCode(LongName = "Belgium, Netherlands", RedumpOrgCode = "Be,N")] + BelgiumNetherlands, + + [RegionCode(LongName = "Europe, Asia", RedumpOrgCode = "E,A")] + EuropeAsia, + + [RegionCode(LongName = "Europe, Australia", RedumpOrgCode = "E,Au")] + EuropeAustralia, + + [RegionCode(LongName = "Europe, Canada", RedumpOrgCode = "E,Ca")] + EuropeCanada, + + [RegionCode(LongName = "Europe, Germany", RedumpOrgCode = "E,G")] + EuropeGermany, + + [RegionCode(LongName = "France, Spain", RedumpOrgCode = "F,S")] + FranceSpain, + + [RegionCode(LongName = "Greater China", RedumpOrgCode = "GC")] + GreaterChina, + + [RegionCode(LongName = "Japan, Asia", RedumpOrgCode = "J,A")] + JapanAsia, + + [RegionCode(LongName = "Japan, Europe", RedumpOrgCode = "J,E")] + JapanEurope, + + [RegionCode(LongName = "Japan, Korea", RedumpOrgCode = "J,K")] + JapanKorea, + + [RegionCode(LongName = "Japan, USA", RedumpOrgCode = "J,U")] + JapanUSA, + + [RegionCode(LongName = "Spain, Portugal", RedumpOrgCode = "S,Pt")] + SpainPortugal, + + [RegionCode(LongName = "UK, Australia", RedumpOrgCode = "Uk,Au")] + UKAustralia, + + [RegionCode(LongName = "USA, Asia", RedumpOrgCode = "U,A")] + USAAsia, + + [RegionCode(LongName = "USA, Australia", RedumpOrgCode = "U,Au")] + USAAustralia, + + [RegionCode(LongName = "USA, Brazil", RedumpOrgCode = "U,B")] + USABrazil, + + [RegionCode(LongName = "USA, Canada", RedumpOrgCode = "U,Ca")] + USACanada, + + [RegionCode(LongName = "USA, Europe", RedumpOrgCode = "U,E")] + USAEurope, + + [RegionCode(LongName = "USA, Germany", RedumpOrgCode = "U,G")] + USAGermany, + + [RegionCode(LongName = "USA, Japan", RedumpOrgCode = "U,J")] + USAJapan, + + [RegionCode(LongName = "USA, Korea", RedumpOrgCode = "U,K")] + USAKorea, + + #endregion + + #region A + + [RegionCode(LongName = "Afghanistan", ShortName = "af", RedumpOrgCode = "Af")] + Afghanistan, + + [RegionCode(LongName = "Åland Islands", ShortName = "ax", RedumpOrgCode = "Ax")] + AlandIslands, + + [RegionCode(LongName = "Albania", ShortName = "al", RedumpOrgCode = "Al")] + Albania, + + [RegionCode(LongName = "Algeria", ShortName = "dz", RedumpOrgCode = "Dz")] + Algeria, + + [RegionCode(LongName = "American Samoa", ShortName = "as", RedumpOrgCode = "As")] + AmericanSamoa, + + [RegionCode(LongName = "Andorra", ShortName = "ad", RedumpOrgCode = "Ad")] + Andorra, + + [RegionCode(LongName = "Angola", ShortName = "ao", RedumpOrgCode = "Ao")] + Angola, + + [RegionCode(LongName = "Anguilla", ShortName = "ai", RedumpOrgCode = "Ai")] + Anguilla, + + [RegionCode(LongName = "Antarctica", ShortName = "aq", RedumpOrgCode = "Aq")] + Antarctica, + + [RegionCode(LongName = "Antigua and Barbuda", ShortName = "ag", RedumpOrgCode = "Ag")] + AntiguaAndBarbuda, + + [RegionCode(LongName = "Argentina", ShortName = "ar", RedumpOrgCode = "Ar")] + Argentina, + + [RegionCode(LongName = "Armenia", ShortName = "am", RedumpOrgCode = "Am")] + Armenia, + + [RegionCode(LongName = "Aruba", ShortName = "aw", RedumpOrgCode = "Aw")] + Aruba, + + [RegionCode(LongName = "Ascension Island", ShortName = "ac", RedumpOrgCode = "Ac")] + AscensionIsland, + + [RegionCode(LongName = "Australia", ShortName = "au", RedumpOrgCode = "Au")] + Australia, + + [RegionCode(LongName = "Austria", ShortName = "at", RedumpOrgCode = "At")] + Austria, + + [RegionCode(LongName = "Azerbaijan", ShortName = "az", RedumpOrgCode = "Az")] + Azerbaijan, + + #endregion + + #region B + + [RegionCode(LongName = "Bahamas", ShortName="bs", RedumpOrgCode="Bs")] + Bahamas, + + [RegionCode(LongName = "Bahrain", ShortName="bh", RedumpOrgCode="Bh")] + Bahrain, + + [RegionCode(LongName = "Bangladesh", ShortName="bd", RedumpOrgCode="Bd")] + Bangladesh, + + [RegionCode(LongName = "Barbados", ShortName="bb", RedumpOrgCode="Bb")] + Barbados, + + [RegionCode(LongName = "Belarus", ShortName="by", RedumpOrgCode="By")] + Belarus, + + [RegionCode(LongName = "Belgium", ShortName="be", RedumpOrgCode="Be")] + Belgium, + + [RegionCode(LongName = "Belize", ShortName="bz", RedumpOrgCode="Bz")] + Belize, + + [RegionCode(LongName = "Benin", ShortName="bj", RedumpOrgCode="Bj")] + Benin, + + [RegionCode(LongName = "Bermuda", ShortName="bm", RedumpOrgCode="Bm")] + Bermuda, + + [RegionCode(LongName = "Bhutan", ShortName="bt", RedumpOrgCode="Bt")] + Bhutan, + + [RegionCode(LongName = "Bolivia", ShortName="bo", RedumpOrgCode="Bo")] + Bolivia, + + [RegionCode(LongName = "Bonaire, Sint Eustatius and Saba", ShortName="bq", RedumpOrgCode="Bq")] + Bonaire, + + [RegionCode(LongName = "Bosnia and Herzegovina", ShortName="ba", RedumpOrgCode="Ba")] + BosniaAndHerzegovina, + + [RegionCode(LongName = "Botswana", ShortName="bw", RedumpOrgCode="Bw")] + Botswana, + + [RegionCode(LongName = "Bouvet Island", ShortName="bv", RedumpOrgCode="Bv")] + BouvetIsland, + + [RegionCode(LongName = "Brazil", ShortName="br", RedumpOrgCode="B")] + Brazil, + + [RegionCode(LongName = "British Indian Ocean Territory", ShortName="io", RedumpOrgCode="Io")] + BritishIndianOceanTerritory, + + [RegionCode(LongName = "Brunei Darussalam", ShortName="bn", RedumpOrgCode="Bn")] + BruneiDarussalam, + + [RegionCode(LongName = "Bulgaria", ShortName="bg", RedumpOrgCode="Bg")] + Bulgaria, + + [RegionCode(LongName = "Burkina Faso", ShortName="bf", RedumpOrgCode="Bf")] + BurkinaFaso, + + [RegionCode(LongName = "Burundi", ShortName="bi", RedumpOrgCode="Bi")] + Burundi, + + #endregion + + #region C + + [RegionCode(LongName = "Cabo Verde", ShortName="cv", RedumpOrgCode="Cv")] + CaboVerde, + + [RegionCode(LongName = "Cambodia", ShortName="kh", RedumpOrgCode="Kh")] + Cambodia, + + [RegionCode(LongName = "Cameroon", ShortName="cm", RedumpOrgCode="Cm")] + Cameroon, + + [RegionCode(LongName = "Canada", ShortName="ca", RedumpOrgCode="Ca")] + Canada, + + [RegionCode(LongName = "Canary Islands", ShortName="ic", RedumpOrgCode="Ic")] + CanaryIslands, + + [RegionCode(LongName = "Cayman Islands", ShortName="ky", RedumpOrgCode="Ky")] + CaymanIslands, + + [RegionCode(LongName = "Central African Republic", ShortName="cf", RedumpOrgCode="Cf")] + CentralAfricanRepublic, + + [RegionCode(LongName = "Ceuta, Melilla", ShortName="ea", RedumpOrgCode="Ea")] + CeutaMelilla, + + [RegionCode(LongName = "Chad", ShortName="td", RedumpOrgCode="Td")] + Chad, + + [RegionCode(LongName = "Chile", ShortName="cl", RedumpOrgCode="Cl")] + Chile, + + [RegionCode(LongName = "China", ShortName="cn", RedumpOrgCode="C")] + China, + + [RegionCode(LongName = "Christmas Island", ShortName="cx", RedumpOrgCode="Cx")] + ChristmasIsland, + + [RegionCode(LongName = "Clipperton Island", ShortName="cp", RedumpOrgCode="Cp")] + ClippertonIsland, + + [RegionCode(LongName = "Cocos (Keeling) Islands", ShortName="cc", RedumpOrgCode="Cc")] + CocosIslands, + + [RegionCode(LongName = "Colombia", ShortName="co", RedumpOrgCode="Co")] + Colombia, + + [RegionCode(LongName = "Comoros", ShortName="km", RedumpOrgCode="Km")] + Comoros, + + [RegionCode(LongName = "Congo", ShortName="cg", RedumpOrgCode="Cg")] + Congo, + + [RegionCode(LongName = "Cook Islands", ShortName="ck", RedumpOrgCode="Ck")] + CookIslands, + + [RegionCode(LongName = "Costa Rica", ShortName="cr", RedumpOrgCode="Cr")] + CostaRica, + + [RegionCode(LongName = "Côte d'Ivoire", ShortName="ci", RedumpOrgCode="Ci")] + CoteDIvoire, + + [RegionCode(LongName = "Croatia", ShortName="hr", RedumpOrgCode="Hr")] + Croatia, + + [RegionCode(LongName = "Cuba", ShortName="cu", RedumpOrgCode="Cu")] + Cuba, + + [RegionCode(LongName = "Curaçao", ShortName="cw", RedumpOrgCode="Cw")] + Curacao, + + [RegionCode(LongName = "Cyprus", ShortName="cy", RedumpOrgCode="Cy")] + Cyprus, + + [RegionCode(LongName = "Czechia", ShortName="cz", RedumpOrgCode="Cz")] + Czechia, + + [RegionCode(LongName = "Czechoslovakia", ShortName="cs", RedumpOrgCode="Cs")] + Czechoslovakia, + + #endregion + + #region D + + // Zaire was "Zr" + [RegionCode(LongName = "Democratic Republic of the Congo (Zaire)", ShortName="cd", RedumpOrgCode="Cd")] + DemocraticRepublicOfTheCongo, + + [RegionCode(LongName = "Denmark", ShortName="dk", RedumpOrgCode="Dk")] + Denmark, + + [RegionCode(LongName = "Diego Garcia", ShortName="dg", RedumpOrgCode="Dg")] + DiegoGarcia, + + [RegionCode(LongName = "Djibouti", ShortName="dj", RedumpOrgCode="Dj")] + Djibouti, + + [RegionCode(LongName = "Dominica", ShortName="dm", RedumpOrgCode="Dm")] + Dominica, + + [RegionCode(LongName = "Dominican Republic", ShortName="do", RedumpOrgCode="Do")] + DominicanRepublic, + + #endregion + + #region E + + [RegionCode(LongName = "Ecuador", ShortName="ec", RedumpOrgCode="Ec")] + Ecuador, + + [RegionCode(LongName = "Egypt", ShortName="eg", RedumpOrgCode="Eg")] + Egypt, + + [RegionCode(LongName = "El Salvador", ShortName="sv", RedumpOrgCode="Sv")] + ElSalvador, + + [RegionCode(LongName = "Equatorial Guinea", ShortName="gq", RedumpOrgCode="Gq")] + EquatorialGuinea, + + [RegionCode(LongName = "Eritrea", ShortName="er", RedumpOrgCode="Er")] + Eritrea, + + [RegionCode(LongName = "Estonia", ShortName="ee", RedumpOrgCode="Ee")] + Estonia, + + [RegionCode(LongName = "Eswatini", ShortName="sz", RedumpOrgCode="Sz")] + Eswatini, + + [RegionCode(LongName = "Ethiopia", ShortName="et", RedumpOrgCode="Et")] + Ethiopia, + + // Commented out to avoid confusion + //[RegionCode(LongName = "European Union", ShortName="eu", RedumpOrgCode="Eu")] + //EuropeanUnion, + + // Commented out to avoid confusion + //[RegionCode(LongName = "Eurozone", ShortName="ez", RedumpOrgCode="Ez")] + //Eurozone, + + #endregion + + #region F + + [RegionCode(LongName = "Falkland Islands (Malvinas)", ShortName="fk", RedumpOrgCode="Fk")] + FalklandIslands, + + [RegionCode(LongName = "Faroe Islands", ShortName="fo", RedumpOrgCode="Fo")] + FaroeIslands, + + [RegionCode(LongName = "Federated States of Micronesia", ShortName="fm", RedumpOrgCode="Fm")] + FederatedStatesOfMicronesia, + + [RegionCode(LongName = "Fiji", ShortName="fj", RedumpOrgCode="Fj")] + Fiji, + + // Formerly "Sf" + [RegionCode(LongName = "Finland", ShortName="fi", RedumpOrgCode="Fi")] + Finland, + + [RegionCode(LongName = "France", ShortName="fr", RedumpOrgCode="F")] + France, + + // Commented out to avoid confusion + //[RegionCode(LongName = "France, Metropolitan", ShortName="fx", RedumpOrgCode="Fx")] + //FranceMetropolitan, + + [RegionCode(LongName = "French Guiana", ShortName="gf", RedumpOrgCode="Gf")] + FrenchGuiana, + + [RegionCode(LongName = "French Polynesia", ShortName="pf", RedumpOrgCode="Pf")] + FrenchPolynesia, + + [RegionCode(LongName = "French Southern Territories", ShortName="tf", RedumpOrgCode="Tf")] + FrenchSouthernTerritories, + + #endregion + + #region G + + [RegionCode(LongName = "Gabon", ShortName="ga", RedumpOrgCode="Ga")] + Gabon, + + [RegionCode(LongName = "Gambia", ShortName="gm", RedumpOrgCode="Gm")] + Gambia, + + [RegionCode(LongName = "Georgia", ShortName="ge", RedumpOrgCode="Ge")] + Georgia, + + [RegionCode(LongName = "Germany", ShortName="de", RedumpOrgCode="G")] + Germany, + + [RegionCode(LongName = "Ghana", ShortName="gh", RedumpOrgCode="Gh")] + Ghana, + + [RegionCode(LongName = "Gibraltar", ShortName="gi", RedumpOrgCode="Gi")] + Gibraltar, + + [RegionCode(LongName = "Greece", ShortName="gr", RedumpOrgCode="Gr")] + Greece, + + [RegionCode(LongName = "Greenland", ShortName="gl", RedumpOrgCode="Gl")] + Greenland, + + [RegionCode(LongName = "Grenada", ShortName="gd", RedumpOrgCode="Gd")] + Grenada, + + [RegionCode(LongName = "Guadeloupe", ShortName="gp", RedumpOrgCode="Gp")] + Guadeloupe, + + [RegionCode(LongName = "Guam", ShortName="gu", RedumpOrgCode="Gu")] + Guam, + + [RegionCode(LongName = "Guatemala", ShortName="gt", RedumpOrgCode="Gt")] + Guatemala, + + [RegionCode(LongName = "Guernsey", ShortName="gg", RedumpOrgCode="Gg")] + Guernsey, + + [RegionCode(LongName = "Guinea", ShortName="gn", RedumpOrgCode="Gn")] + Guinea, + + [RegionCode(LongName = "Guinea-Bissau", ShortName="gw", RedumpOrgCode="Gw")] + GuineaBissau, + + [RegionCode(LongName = "Guyana", ShortName="gy", RedumpOrgCode="Gy")] + Guyana, + + #endregion + + #region H + + [RegionCode(LongName = "Haiti", ShortName="ht", RedumpOrgCode="Ht")] + Haiti, + + [RegionCode(LongName = "Heard Island and McDonald Islands", ShortName="hm", RedumpOrgCode="Hm")] + HeardIslandAndMcDonaldIslands, + + [RegionCode(LongName = "Holy See (Vatican City)", ShortName="va", RedumpOrgCode="Va")] + HolySee, + + [RegionCode(LongName = "Honduras", ShortName="hn", RedumpOrgCode="Hn")] + Honduras, + + [RegionCode(LongName = "Hong Kong", ShortName="hk", RedumpOrgCode="Hk")] + HongKong, + + [RegionCode(LongName = "Hungary", ShortName="hu", RedumpOrgCode="H")] + Hungary, + + #endregion + + #region I + + [RegionCode(LongName = "Iceland", ShortName="is", RedumpOrgCode="Is")] + Iceland, + + [RegionCode(LongName = "India", ShortName="in", RedumpOrgCode="In")] + India, + + [RegionCode(LongName = "Indonesia", ShortName="id", RedumpOrgCode="Id")] + Indonesia, + + [RegionCode(LongName = "Iran", ShortName="ir", RedumpOrgCode="Ir")] + Iran, + + [RegionCode(LongName = "Iraq", ShortName="iq", RedumpOrgCode="Iq")] + Iraq, + + [RegionCode(LongName = "Ireland", ShortName="ie", RedumpOrgCode="Ie")] + Ireland, + + [RegionCode(LongName = "Island of Sark", ShortName="cq", RedumpOrgCode="Cq")] + IslandOfSark, + + [RegionCode(LongName = "Isle of Man", ShortName="im", RedumpOrgCode="Im")] + IsleOfMan, + + [RegionCode(LongName = "Israel", ShortName="il", RedumpOrgCode="Il")] + Israel, + + [RegionCode(LongName = "Italy", ShortName="it", RedumpOrgCode="I")] + Italy, + + #endregion + + #region J + + [RegionCode(LongName = "Jamaica", ShortName="jm", RedumpOrgCode="Jm")] + Jamaica, + + [RegionCode(LongName = "Japan", ShortName="jp", RedumpOrgCode="J")] + Japan, + + [RegionCode(LongName = "Jersey", ShortName="je", RedumpOrgCode="Je")] + Jersey, + + [RegionCode(LongName = "Jordan", ShortName="jo", RedumpOrgCode="Jo")] + Jordan, + + #endregion + + #region K + + [RegionCode(LongName = "Kazakhstan", ShortName="kz", RedumpOrgCode="Kz")] + Kazakhstan, + + [RegionCode(LongName = "Kenya", ShortName="ke", RedumpOrgCode="Ke")] + Kenya, + + [RegionCode(LongName = "Kiribati", ShortName="ki", RedumpOrgCode="Ki")] + Kiribati, + + [RegionCode(LongName = "Korea (Democratic People's Republic of Korea)", ShortName="kp", RedumpOrgCode="Kp")] + NorthKorea, + + [RegionCode(LongName = "Korea (Republic of Korea)", ShortName="kr", RedumpOrgCode="K")] + SouthKorea, + + [RegionCode(LongName = "Kuwait", ShortName="kw", RedumpOrgCode="Kw")] + Kuwait, + + [RegionCode(LongName = "Kyrgyzstan", ShortName="kg", RedumpOrgCode="Kg")] + Kyrgyzstan, + + #endregion + + #region L + + [RegionCode(LongName = "(Laos) Lao People's Democratic Republic", ShortName="la", RedumpOrgCode="La")] + Laos, + + [RegionCode(LongName = "Latvia", ShortName="lv", RedumpOrgCode="Lv")] + Latvia, + + [RegionCode(LongName = "Lebanon", ShortName="lb", RedumpOrgCode="Lb")] + Lebanon, + + [RegionCode(LongName = "Lesotho", ShortName="ls", RedumpOrgCode="Ls")] + Lesotho, + + [RegionCode(LongName = "Liberia", ShortName="lr", RedumpOrgCode="Lr")] + Liberia, + + [RegionCode(LongName = "Libya", ShortName="ly", RedumpOrgCode="Ly")] + Libya, + + [RegionCode(LongName = "Liechtenstein", ShortName="li", RedumpOrgCode="Li")] + Liechtenstein, + + [RegionCode(LongName = "Lithuania", ShortName="lt", RedumpOrgCode="Lt")] + Lithuania, + + [RegionCode(LongName = "Luxembourg", ShortName="lu", RedumpOrgCode="Lu")] + Luxembourg, + + #endregion + + #region M + + [RegionCode(LongName = "Macao", ShortName="mo", RedumpOrgCode="Mo")] + Macao, + + [RegionCode(LongName = "Madagascar", ShortName="mg", RedumpOrgCode="Mg")] + Madagascar, + + [RegionCode(LongName = "Malawi", ShortName="mw", RedumpOrgCode="Mw")] + Malawi, + + [RegionCode(LongName = "Malaysia", ShortName="my", RedumpOrgCode="My")] + Malaysia, + + [RegionCode(LongName = "Maldives", ShortName="mv", RedumpOrgCode="Mv")] + Maldives, + + [RegionCode(LongName = "Mali", ShortName="ml", RedumpOrgCode="Ml")] + Mali, + + [RegionCode(LongName = "Malta", ShortName="mt", RedumpOrgCode="Mt")] + Malta, + + [RegionCode(LongName = "Marshall Islands", ShortName="mh", RedumpOrgCode="Mh")] + MarshallIslands, + + [RegionCode(LongName = "Martinique", ShortName="mq", RedumpOrgCode="Mq")] + Martinique, + + [RegionCode(LongName = "Mauritania", ShortName="mr", RedumpOrgCode="Mr")] + Mauritania, + + [RegionCode(LongName = "Mauritius", ShortName="mu", RedumpOrgCode="Mu")] + Mauritius, + + [RegionCode(LongName = "Mayotte", ShortName="yt", RedumpOrgCode="Yt")] + Mayotte, + + [RegionCode(LongName = "Mexico", ShortName="mx", RedumpOrgCode="Mx")] + Mexico, + + [RegionCode(LongName = "Monaco", ShortName="mc", RedumpOrgCode="Mc")] + Monaco, + + [RegionCode(LongName = "Mongolia", ShortName="mn", RedumpOrgCode="Mn")] + Mongolia, + + [RegionCode(LongName = "Montenegro", ShortName="me", RedumpOrgCode="Me")] + Montenegro, + + [RegionCode(LongName = "Montserrat", ShortName="ms", RedumpOrgCode="Ms")] + Montserrat, + + [RegionCode(LongName = "Morocco", ShortName="ma", RedumpOrgCode="Ma")] + Morocco, + + [RegionCode(LongName = "Mozambique", ShortName="mz", RedumpOrgCode="Mz")] + Mozambique, + + // Burma was "Bu" + [RegionCode(LongName = "Myanmar (Burma)", ShortName="mm", RedumpOrgCode="Mm")] + Myanmar, + + #endregion + + #region N + + [RegionCode(LongName = "Namibia", ShortName="na", RedumpOrgCode="Na")] + Namibia, + + [RegionCode(LongName = "Nauru", ShortName="nr", RedumpOrgCode="Nr")] + Nauru, + + [RegionCode(LongName = "Nepal", ShortName="np", RedumpOrgCode="Np")] + Nepal, + + [RegionCode(LongName = "Netherlands", ShortName="nl", RedumpOrgCode="N")] + Netherlands, + + [RegionCode(LongName = "Netherlands Antilles", ShortName="an", RedumpOrgCode="An")] + NetherlandsAntilles, + + // Commented out to avoid confusion + //[RegionCode(LongName = "Neutral Zone", ShortName="nt", RedumpOrgCode="Nt")] + //NeutralZone, + + [RegionCode(LongName = "New Caledonia", ShortName="nc", RedumpOrgCode="Nc")] + NewCaledonia, + + [RegionCode(LongName = "New Zealand", ShortName="nz", RedumpOrgCode="Nz")] + NewZealand, + + [RegionCode(LongName = "Nicaragua", ShortName="ni", RedumpOrgCode="Ni")] + Nicaragua, + + [RegionCode(LongName = "Niger", ShortName="ne", RedumpOrgCode="Ne")] + Niger, + + [RegionCode(LongName = "Nigeria", ShortName="ng", RedumpOrgCode="Ng")] + Nigeria, + + [RegionCode(LongName = "Niue", ShortName="nu", RedumpOrgCode="Nu")] + Niue, + + [RegionCode(LongName = "Norfolk Island", ShortName="nf", RedumpOrgCode="Nf")] + NorfolkIsland, + + [RegionCode(LongName = "North Macedonia", ShortName="mk", RedumpOrgCode="Mk")] + NorthMacedonia, + + [RegionCode(LongName = "Northern Mariana Islands", ShortName="mp", RedumpOrgCode="Mp")] + NorthernMarianaIslands, + + [RegionCode(LongName = "Norway", ShortName="no", RedumpOrgCode="No")] + Norway, + + #endregion + + #region O + + [RegionCode(LongName = "Oman", ShortName="om", RedumpOrgCode="Om")] + Oman, + + #endregion + + #region P + + [RegionCode(LongName = "Pakistan", ShortName="pk", RedumpOrgCode="Pk")] + Pakistan, + + [RegionCode(LongName = "Palau", ShortName="pw", RedumpOrgCode="Pw")] + Palau, + + [RegionCode(LongName = "Panama", ShortName="pa", RedumpOrgCode="Pa")] + Panama, + + [RegionCode(LongName = "Papua New Guinea", ShortName="pg", RedumpOrgCode="Pg")] + PapuaNewGuinea, + + [RegionCode(LongName = "Paraguay", ShortName="py", RedumpOrgCode="Py")] + Paraguay, + + [RegionCode(LongName = "Peru", ShortName="pe", RedumpOrgCode="Pe")] + Peru, + + [RegionCode(LongName = "Philippines", ShortName="ph", RedumpOrgCode="Ph")] + Philippines, + + [RegionCode(LongName = "Pitcairn", ShortName="pn", RedumpOrgCode="Pn")] + Pitcairn, + + [RegionCode(LongName = "Poland", ShortName="pl", RedumpOrgCode="P")] + Poland, + + [RegionCode(LongName = "Portugal", ShortName="pt", RedumpOrgCode="Pt")] + Portugal, + + [RegionCode(LongName = "Puerto Rico", ShortName="pr", RedumpOrgCode="Pr")] + PuertoRico, + + #endregion + + #region Q + + [RegionCode(LongName = "Qatar", ShortName="qa", RedumpOrgCode="Qa")] + Qatar, + + #endregion + + #region R + + [RegionCode(LongName = "Republic of Moldova", ShortName="md", RedumpOrgCode="Md")] + RepublicOfMoldova, + + [RegionCode(LongName = "Réunion", ShortName="re", RedumpOrgCode="Re")] + Reunion, + + [RegionCode(LongName = "Romania", ShortName="ro", RedumpOrgCode="Ro")] + Romania, + + [RegionCode(LongName = "Russian Federation", ShortName="ru", RedumpOrgCode="R")] + RussianFederation, + + [RegionCode(LongName = "Rwanda", ShortName="rw", RedumpOrgCode="Rw")] + Rwanda, + + #endregion + + #region S + + [RegionCode(LongName = "Saint Barthélemy", ShortName="bl", RedumpOrgCode="Bl")] + SaintBarthelemy, + + [RegionCode(LongName = "Saint Helena, Ascension and Tristan da Cunha", ShortName="sh", RedumpOrgCode="Sh")] + SaintHelena, + + [RegionCode(LongName = "Saint Kitts and Nevis", ShortName="kn", RedumpOrgCode="Kn")] + SaintKittsAndNevis, + + [RegionCode(LongName = "Saint Lucia", ShortName="lc", RedumpOrgCode="Lc")] + SaintLucia, + + [RegionCode(LongName = "Saint Martin", ShortName="mf", RedumpOrgCode="Mf")] + SaintMartin, + + [RegionCode(LongName = "Saint Pierre and Miquelon", ShortName="pm", RedumpOrgCode="Pm")] + SaintPierreAndMiquelon, + + [RegionCode(LongName = "Saint Vincent and the Grenadines", ShortName="vc", RedumpOrgCode="Vc")] + SaintVincentAndTheGrenadines, + + [RegionCode(LongName = "Samoa", ShortName="ws", RedumpOrgCode="Ws")] + Samoa, + + [RegionCode(LongName = "San Marino", ShortName="sm", RedumpOrgCode="Sm")] + SanMarino, + + [RegionCode(LongName = "Sao Tome and Principe", ShortName="st", RedumpOrgCode="St")] + SaoTomeAndPrincipe, + + [RegionCode(LongName = "Saudi Arabia", ShortName="sa", RedumpOrgCode="Sa")] + SaudiArabia, + + [RegionCode(LongName = "Senegal", ShortName="sn", RedumpOrgCode="Sn")] + Senegal, + + [RegionCode(LongName = "Serbia", ShortName="rs", RedumpOrgCode="Rs")] + Serbia, + + [RegionCode(LongName = "Seychelles", ShortName="sc", RedumpOrgCode="Sc")] + Seychelles, + + [RegionCode(LongName = "Sierra Leone", ShortName="sl", RedumpOrgCode="Sl")] + SierraLeone, + + [RegionCode(LongName = "Singapore", ShortName="sg", RedumpOrgCode="Sg")] + Singapore, + + [RegionCode(LongName = "Sint Maarten", ShortName="sx", RedumpOrgCode="Sx")] + SintMaarten, + + [RegionCode(LongName = "Slovakia", ShortName="sk", RedumpOrgCode="Sk")] + Slovakia, + + [RegionCode(LongName = "Slovenia", ShortName="si", RedumpOrgCode="Si")] + Slovenia, + + [RegionCode(LongName = "Solomon Islands", ShortName="sb", RedumpOrgCode="Sb")] + SolomonIslands, + + [RegionCode(LongName = "Somalia", ShortName="so", RedumpOrgCode="So")] + Somalia, + + [RegionCode(LongName = "South Africa", ShortName="za", RedumpOrgCode="Za")] + SouthAfrica, + + [RegionCode(LongName = "South Georgia and the South Sandwich Islands", ShortName="gs", RedumpOrgCode="Gs")] + SouthGeorgia, + + [RegionCode(LongName = "South Sudan", ShortName="ss", RedumpOrgCode="Ss")] + SouthSudan, + + [RegionCode(LongName = "Spain", ShortName="es", RedumpOrgCode="S")] + Spain, + + [RegionCode(LongName = "Sri Lanka", ShortName="lk", RedumpOrgCode="Lk")] + SriLanka, + + [RegionCode(LongName = "State of Palestine", ShortName="ps", RedumpOrgCode="Ps")] + StateOfPalestine, + + [RegionCode(LongName = "Sudan", ShortName="sd", RedumpOrgCode="Sd")] + Sudan, + + [RegionCode(LongName = "Suriname", ShortName="sr", RedumpOrgCode="Sr")] + Suriname, + + [RegionCode(LongName = "Svalbard and Jan Mayen", ShortName="sj", RedumpOrgCode="Sj")] + SvalbardAndJanMayen, + + [RegionCode(LongName = "Sweden", ShortName="se", RedumpOrgCode="Sw")] + Sweden, + + [RegionCode(LongName = "Switzerland", ShortName="ch", RedumpOrgCode="Ch")] + Switzerland, + + [RegionCode(LongName = "Syrian Arab Republic", ShortName="sy", RedumpOrgCode="Sy")] + SyrianArabRepublic, + + #endregion + + #region T + + [RegionCode(LongName = "Taiwan", ShortName="tw", RedumpOrgCode="Tw")] + Taiwan, + + [RegionCode(LongName = "Tajikistan", ShortName="tj", RedumpOrgCode="Tj")] + Tajikistan, + + [RegionCode(LongName = "Thailand", ShortName="th", RedumpOrgCode="Th")] + Thailand, + + // East Timor was "Tp" + [RegionCode(LongName = "Timor-Leste (East Timor)", ShortName="tl", RedumpOrgCode="Tl")] + TimorLeste, + + [RegionCode(LongName = "Togo", ShortName="tg", RedumpOrgCode="Tg")] + Togo, + + [RegionCode(LongName = "Tokelau", ShortName="tk", RedumpOrgCode="Tk")] + Tokelau, + + [RegionCode(LongName = "Tonga", ShortName="to", RedumpOrgCode="To")] + Tonga, + + [RegionCode(LongName = "Trinidad and Tobago", ShortName="tt", RedumpOrgCode="Tt")] + TrinidadAndTobago, + + [RegionCode(LongName = "Tristan da Cunha", ShortName="ta", RedumpOrgCode="Ta")] + TristanDaCunha, + + [RegionCode(LongName = "Tunisia", ShortName="tn", RedumpOrgCode="Tn")] + Tunisia, + + [RegionCode(LongName = "Turkey", ShortName="tr", RedumpOrgCode="Tr")] + Turkey, + + [RegionCode(LongName = "Turkmenistan", ShortName="tm", RedumpOrgCode="Tm")] + Turkmenistan, + + [RegionCode(LongName = "Turks and Caicos Islands", ShortName="tc", RedumpOrgCode="Tc")] + TurksAndCaicosIslands, + + [RegionCode(LongName = "Tuvalu", ShortName="tv", RedumpOrgCode="Tv")] + Tuvalu, + + #endregion + + #region U + + [RegionCode(LongName = "Uganda", ShortName="ug", RedumpOrgCode="Ug")] + Uganda, + + // Should be both "Gb" and "Uk" + // United Kingdom of Great Britain and Northern Ireland + [RegionCode(LongName = "UK", ShortName="gb", RedumpOrgCode="Uk")] + UnitedKingdom, + + [RegionCode(LongName = "Ukraine", ShortName="ue", RedumpOrgCode="Ue")] + Ukraine, + + [RegionCode(LongName = "United Arab Emirates", ShortName="ae", RedumpOrgCode="Ae")] + UnitedArabEmirates, + + // Commented out to avoid confusion + //[RegionCode(LongName = "United Nations", ShortName="un", RedumpOrgCode="Un")] + //UnitedNations, + + [RegionCode(LongName = "United Republic of Tanzania", ShortName="tz", RedumpOrgCode="Tz")] + UnitedRepublicOfTanzania, + + [RegionCode(LongName = "United States Minor Outlying Islands", ShortName="um", RedumpOrgCode="Um")] + UnitedStatesMinorOutlyingIslands, + + [RegionCode(LongName = "Uruguay", ShortName="uy", RedumpOrgCode="Uy")] + Uruguay, + + // United States of America + [RegionCode(LongName = "USA", ShortName="us", RedumpOrgCode="U")] + UnitedStatesOfAmerica, + + [RegionCode(LongName = "USSR", ShortName="su", RedumpOrgCode="Su")] + USSR, + + [RegionCode(LongName = "Uzbekistan", ShortName="uz", RedumpOrgCode="Uz")] + Uzbekistan, + + #endregion + + #region V + + [RegionCode(LongName = "Vanuatu", ShortName="vu", RedumpOrgCode="Vu")] + Vanuatu, + + [RegionCode(LongName = "Venezuela", ShortName="ve", RedumpOrgCode="Ve")] + Venezuela, + + [RegionCode(LongName = "Viet Nam", ShortName="vn", RedumpOrgCode="Vn")] + VietNam, + + [RegionCode(LongName = "Virgin Islands (British)", ShortName="vg", RedumpOrgCode="Vg")] + BritishVirginIslands, + + [RegionCode(LongName = "Virgin Islands (US)", ShortName="vi", RedumpOrgCode="Vi")] + USVirginIslands, + + #endregion + + #region W + + [RegionCode(LongName = "Wallis and Futuna", ShortName="wf", RedumpOrgCode="Wf")] + WallisAndFutuna, + + [RegionCode(LongName = "Western Sahara", ShortName="eh", RedumpOrgCode="Eh")] + WesternSahara, + + #endregion + + #region Y + + [RegionCode(LongName = "Yemen", ShortName="ye", RedumpOrgCode="Ye")] + Yemen, + + [RegionCode(LongName = "Yugoslavia", ShortName="yu", RedumpOrgCode="Yu")] + Yugoslavia, + + #endregion + + #region Z + + [RegionCode(LongName = "Zambia", ShortName="zm", RedumpOrgCode="Zm")] + Zambia, + + [RegionCode(LongName = "Zimbabwe", ShortName="zw", RedumpOrgCode="Zw")] + Zimbabwe, + + #endregion + } } diff --git a/SabreTools.RedumpLib/Data/Extensions.cs b/SabreTools.RedumpLib/Data/Extensions.cs index 9ecce1f..4af5a31 100644 --- a/SabreTools.RedumpLib/Data/Extensions.cs +++ b/SabreTools.RedumpLib/Data/Extensions.cs @@ -195,5 +195,90 @@ namespace SabreTools.RedumpLib.Data => AttributeHelper.GetHumanReadableAttribute(mediaType)?.ShortName; #endregion + + #region Region + + /// + /// Get the Redump longnames for each known region + /// + /// + /// + public static string? LongName(this Region region) + => (AttributeHelper.GetHumanReadableAttribute(region) as RegionCodeAttribute)?.LongName; + + /// + /// Get the Redump longnames for each known region + /// + /// + /// + public static string? LongName(this Region? region) + => (AttributeHelper.GetHumanReadableAttribute(region) as RegionCodeAttribute)?.LongName; + + /// + /// Get the Redump shortnames for each known region + /// + /// + /// + public static string? ShortName(this Region region) + => (AttributeHelper.GetHumanReadableAttribute(region) as RegionCodeAttribute)?.ShortName; + + /// + /// Get the Redump shortnames for each known region + /// + /// + /// + public static string? ShortName(this Region? region) + => (AttributeHelper.GetHumanReadableAttribute(region) as RegionCodeAttribute)?.ShortName; + + /// + /// Get the Redump shortnames for each known region + /// + /// + /// + public static string? ShortNameAlt(this Region region) + => (AttributeHelper.GetHumanReadableAttribute(region) as RegionCodeAttribute)?.RedumpOrgCode; + + /// + /// Get the Redump shortnames for each known region + /// + /// + /// + public static string? ShortNameAlt(this Region? region) + => (AttributeHelper.GetHumanReadableAttribute(region) as RegionCodeAttribute)?.RedumpOrgCode; + + /// + /// Get the Region enum value for a given string + /// + /// String value to convert + /// Region represented by the string, if possible + public static Region? ToRegion(this string? region) + { + // No value means no match + if (region is null || region.Length == 0) + return null; + + region = region.ToLowerInvariant(); + var redumpSystems = (Region[])Enum.GetValues(typeof(Region)); + + // Check short names + int index = Array.FindIndex(redumpSystems, s => region == s.ShortName()?.ToLowerInvariant()); + if (index > -1) + return redumpSystems[index]; + + // Check redump.org short names + index = Array.FindIndex(redumpSystems, s => region == s.ShortNameAlt()?.ToLowerInvariant()); + if (index > -1) + return redumpSystems[index]; + + // Check long names + index = Array.FindIndex(redumpSystems, s => region == s.LongName()?.ToLowerInvariant() + || region == s.LongName()?.Replace(" ", string.Empty)?.ToLowerInvariant()); + if (index > -1) + return redumpSystems[index]; + + return null; + } + + #endregion } } diff --git a/SabreTools.RedumpLib/RedumpInfo/Client.cs b/SabreTools.RedumpLib/RedumpInfo/Client.cs index 0a01d15..dd89def 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Client.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Client.cs @@ -9,6 +9,7 @@ using System.Net.Http.Headers; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.RedumpInfo.Data; using SabreTools.RedumpLib.Web; using static SabreTools.RedumpLib.RedumpOrg.Data.Extensions; diff --git a/SabreTools.RedumpLib/RedumpInfo/Converters/RegionConverter.cs b/SabreTools.RedumpLib/RedumpInfo/Converters/RegionConverter.cs index 4333be8..21a241b 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Converters/RegionConverter.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Converters/RegionConverter.cs @@ -1,6 +1,7 @@ using System; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.RedumpInfo.Data; namespace SabreTools.RedumpLib.RedumpInfo.Converters diff --git a/SabreTools.RedumpLib/RedumpInfo/Data/Enumerations.cs b/SabreTools.RedumpLib/RedumpInfo/Data/Enumerations.cs index ab1ffc8..a82cc96 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Data/Enumerations.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Data/Enumerations.cs @@ -759,944 +759,6 @@ namespace SabreTools.RedumpLib.RedumpInfo.Data #endregion } - /// - /// List of all known regions - /// - /// - /// https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 - /// - public enum Region - { - #region Aggregates - Redump Only - - [HumanReadable(LongName = "Asia", ShortName = "xa")] - Asia, - - [HumanReadable(LongName = "Europe", ShortName = "eu")] - Europe, - - [HumanReadable(LongName = "Export", ShortName = "xp")] - Export, - - [HumanReadable(LongName = "Latin America", ShortName = "xl")] - LatinAmerica, - - [HumanReadable(LongName = "Scandinavia", ShortName = "xs")] - Scandinavia, - - [HumanReadable(LongName = "World", ShortName = "un")] - World, - - #endregion - - #region A - - [HumanReadable(LongName = "Afghanistan", ShortName = "af")] - Afghanistan, - - [HumanReadable(LongName = "Åland Islands", ShortName = "ax")] - AlandIslands, - - [HumanReadable(LongName = "Albania", ShortName = "al")] - Albania, - - [HumanReadable(LongName = "Algeria", ShortName = "dz")] - Algeria, - - [HumanReadable(LongName = "American Samoa", ShortName = "as")] - AmericanSamoa, - - [HumanReadable(LongName = "Andorra", ShortName = "ad")] - Andorra, - - [HumanReadable(LongName = "Angola", ShortName = "ao")] - Angola, - - [HumanReadable(LongName = "Anguilla", ShortName = "ai")] - Anguilla, - - [HumanReadable(LongName = "Antarctica", ShortName = "aq")] - Antarctica, - - [HumanReadable(LongName = "Antigua and Barbuda", ShortName = "ag")] - AntiguaAndBarbuda, - - [HumanReadable(LongName = "Argentina", ShortName = "ar")] - Argentina, - - [HumanReadable(LongName = "Armenia", ShortName = "am")] - Armenia, - - [HumanReadable(LongName = "Aruba", ShortName = "aw")] - Aruba, - - [HumanReadable(LongName = "Ascension Island", ShortName = "ac")] - AscensionIsland, - - [HumanReadable(LongName = "Australia", ShortName = "au")] - Australia, - - [HumanReadable(LongName = "Austria", ShortName = "at")] - Austria, - - [HumanReadable(LongName = "Azerbaijan", ShortName = "az")] - Azerbaijan, - - #endregion - - #region B - - [HumanReadable(LongName = "Bahamas", ShortName = "bs")] - Bahamas, - - [HumanReadable(LongName = "Bahrain", ShortName = "bh")] - Bahrain, - - [HumanReadable(LongName = "Bangladesh", ShortName = "bd")] - Bangladesh, - - [HumanReadable(LongName = "Barbados", ShortName = "bb")] - Barbados, - - [HumanReadable(LongName = "Belarus", ShortName = "by")] - Belarus, - - [HumanReadable(LongName = "Belgium", ShortName = "be")] - Belgium, - - [HumanReadable(LongName = "Belize", ShortName = "bz")] - Belize, - - [HumanReadable(LongName = "Benin", ShortName = "bj")] - Benin, - - [HumanReadable(LongName = "Bermuda", ShortName = "bm")] - Bermuda, - - [HumanReadable(LongName = "Bhutan", ShortName = "bt")] - Bhutan, - - [HumanReadable(LongName = "Bolivia", ShortName = "bo")] - Bolivia, - - [HumanReadable(LongName = "Bonaire, Sint Eustatius and Saba", ShortName = "bq")] - Bonaire, - - [HumanReadable(LongName = "Bosnia and Herzegovina", ShortName = "ba")] - BosniaAndHerzegovina, - - [HumanReadable(LongName = "Botswana", ShortName = "bw")] - Botswana, - - [HumanReadable(LongName = "Bouvet Island", ShortName = "bv")] - BouvetIsland, - - [HumanReadable(LongName = "Brazil", ShortName = "br")] - Brazil, - - [HumanReadable(LongName = "British Indian Ocean Territory", ShortName = "io")] - BritishIndianOceanTerritory, - - [HumanReadable(LongName = "Brunei Darussalam", ShortName = "bn")] - BruneiDarussalam, - - [HumanReadable(LongName = "Bulgaria", ShortName = "bg")] - Bulgaria, - - [HumanReadable(LongName = "Burkina Faso", ShortName = "bf")] - BurkinaFaso, - - [HumanReadable(LongName = "Burundi", ShortName = "bi")] - Burundi, - - #endregion - - #region C - - [HumanReadable(LongName = "Cabo Verde", ShortName = "cv")] - CaboVerde, - - [HumanReadable(LongName = "Cambodia", ShortName = "kh")] - Cambodia, - - [HumanReadable(LongName = "Cameroon", ShortName = "cm")] - Cameroon, - - [HumanReadable(LongName = "Canada", ShortName = "ca")] - Canada, - - [HumanReadable(LongName = "Canary Islands", ShortName = "ic")] - CanaryIslands, - - [HumanReadable(LongName = "Cayman Islands", ShortName = "ky")] - CaymanIslands, - - [HumanReadable(LongName = "Central African Republic", ShortName = "cf")] - CentralAfricanRepublic, - - [HumanReadable(LongName = "Ceuta, Melilla", ShortName = "ea")] - CeutaMelilla, - - [HumanReadable(LongName = "Chad", ShortName = "td")] - Chad, - - [HumanReadable(LongName = "Chile", ShortName = "cl")] - Chile, - - [HumanReadable(LongName = "China", ShortName = "cn")] - China, - - [HumanReadable(LongName = "Christmas Island", ShortName = "cx")] - ChristmasIsland, - - [HumanReadable(LongName = "Clipperton Island", ShortName = "cp")] - ClippertonIsland, - - [HumanReadable(LongName = "Cocos (Keeling) Islands", ShortName = "cc")] - CocosIslands, - - [HumanReadable(LongName = "Colombia", ShortName = "co")] - Colombia, - - [HumanReadable(LongName = "Comoros", ShortName = "km")] - Comoros, - - [HumanReadable(LongName = "Congo", ShortName = "cg")] - Congo, - - [HumanReadable(LongName = "Cook Islands", ShortName = "ck")] - CookIslands, - - [HumanReadable(LongName = "Costa Rica", ShortName = "cr")] - CostaRica, - - [HumanReadable(LongName = "Côte d'Ivoire", ShortName = "ci")] - CoteDIvoire, - - [HumanReadable(LongName = "Croatia", ShortName = "hr")] - Croatia, - - [HumanReadable(LongName = "Cuba", ShortName = "cu")] - Cuba, - - [HumanReadable(LongName = "Curaçao", ShortName = "cw")] - Curacao, - - [HumanReadable(LongName = "Cyprus", ShortName = "cy")] - Cyprus, - - [HumanReadable(LongName = "Czechia", ShortName = "cz")] - Czechia, - - [HumanReadable(LongName = "Czechoslovakia", ShortName = "cs")] - Czechoslovakia, - - #endregion - - #region D - - // Zaire was "Zr" - [HumanReadable(LongName = "Democratic Republic of the Congo (Zaire)", ShortName = "cd")] - DemocraticRepublicOfTheCongo, - - [HumanReadable(LongName = "Denmark", ShortName = "dk")] - Denmark, - - [HumanReadable(LongName = "Diego Garcia", ShortName = "dg")] - DiegoGarcia, - - [HumanReadable(LongName = "Djibouti", ShortName = "dj")] - Djibouti, - - [HumanReadable(LongName = "Dominica", ShortName = "dm")] - Dominica, - - [HumanReadable(LongName = "Dominican Republic", ShortName = "do")] - DominicanRepublic, - - #endregion - - #region E - - [HumanReadable(LongName = "Ecuador", ShortName = "ec")] - Ecuador, - - [HumanReadable(LongName = "Egypt", ShortName = "eg")] - Egypt, - - [HumanReadable(LongName = "El Salvador", ShortName = "sv")] - ElSalvador, - - [HumanReadable(LongName = "Equatorial Guinea", ShortName = "gq")] - EquatorialGuinea, - - [HumanReadable(LongName = "Eritrea", ShortName = "er")] - Eritrea, - - [HumanReadable(LongName = "Estonia", ShortName = "ee")] - Estonia, - - [HumanReadable(LongName = "Eswatini", ShortName = "sz")] - Eswatini, - - [HumanReadable(LongName = "Ethiopia", ShortName = "et")] - Ethiopia, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "European Union", ShortName="eu")] - //EuropeanUnion, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "Eurozone", ShortName="ez")] - //Eurozone, - - #endregion - - #region F - - [HumanReadable(LongName = "Falkland Islands (Malvinas)", ShortName = "fk")] - FalklandIslands, - - [HumanReadable(LongName = "Faroe Islands", ShortName = "fo")] - FaroeIslands, - - [HumanReadable(LongName = "Federated States of Micronesia", ShortName = "fm")] - FederatedStatesOfMicronesia, - - [HumanReadable(LongName = "Fiji", ShortName = "fj")] - Fiji, - - // Formerly "Sf" - [HumanReadable(LongName = "Finland", ShortName = "fi")] - Finland, - - [HumanReadable(LongName = "France", ShortName = "fr")] - France, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "France, Metropolitan", ShortName="fx")] - //FranceMetropolitan, - - [HumanReadable(LongName = "French Guiana", ShortName = "gf")] - FrenchGuiana, - - [HumanReadable(LongName = "French Polynesia", ShortName = "pf")] - FrenchPolynesia, - - [HumanReadable(LongName = "French Southern Territories", ShortName = "tf")] - FrenchSouthernTerritories, - - #endregion - - #region G - - [HumanReadable(LongName = "Gabon", ShortName = "ga")] - Gabon, - - [HumanReadable(LongName = "Gambia", ShortName = "gm")] - Gambia, - - [HumanReadable(LongName = "Georgia", ShortName = "ge")] - Georgia, - - [HumanReadable(LongName = "Germany", ShortName = "de")] - Germany, - - [HumanReadable(LongName = "Ghana", ShortName = "gh")] - Ghana, - - [HumanReadable(LongName = "Gibraltar", ShortName = "gi")] - Gibraltar, - - [HumanReadable(LongName = "Greece", ShortName = "gr")] - Greece, - - [HumanReadable(LongName = "Greenland", ShortName = "gl")] - Greenland, - - [HumanReadable(LongName = "Grenada", ShortName = "gd")] - Grenada, - - [HumanReadable(LongName = "Guadeloupe", ShortName = "gp")] - Guadeloupe, - - [HumanReadable(LongName = "Guam", ShortName = "gu")] - Guam, - - [HumanReadable(LongName = "Guatemala", ShortName = "gt")] - Guatemala, - - [HumanReadable(LongName = "Guernsey", ShortName = "gg")] - Guernsey, - - [HumanReadable(LongName = "Guinea", ShortName = "gn")] - Guinea, - - [HumanReadable(LongName = "Guinea-Bissau", ShortName = "gw")] - GuineaBissau, - - [HumanReadable(LongName = "Guyana", ShortName = "gy")] - Guyana, - - #endregion - - #region H - - [HumanReadable(LongName = "Haiti", ShortName = "ht")] - Haiti, - - [HumanReadable(LongName = "Heard Island and McDonald Islands", ShortName = "hm")] - HeardIslandAndMcDonaldIslands, - - [HumanReadable(LongName = "Holy See (Vatican City)", ShortName = "va")] - HolySee, - - [HumanReadable(LongName = "Honduras", ShortName = "hn")] - Honduras, - - [HumanReadable(LongName = "Hong Kong", ShortName = "hk")] - HongKong, - - [HumanReadable(LongName = "Hungary", ShortName = "hu")] - Hungary, - - #endregion - - #region I - - [HumanReadable(LongName = "Iceland", ShortName = "is")] - Iceland, - - [HumanReadable(LongName = "India", ShortName = "in")] - India, - - [HumanReadable(LongName = "Indonesia", ShortName = "id")] - Indonesia, - - [HumanReadable(LongName = "Iran", ShortName = "ir")] - Iran, - - [HumanReadable(LongName = "Iraq", ShortName = "iq")] - Iraq, - - [HumanReadable(LongName = "Ireland", ShortName = "ie")] - Ireland, - - [HumanReadable(LongName = "Island of Sark", ShortName = "cq")] - IslandOfSark, - - [HumanReadable(LongName = "Isle of Man", ShortName = "im")] - IsleOfMan, - - [HumanReadable(LongName = "Israel", ShortName = "il")] - Israel, - - [HumanReadable(LongName = "Italy", ShortName = "it")] - Italy, - - #endregion - - #region J - - [HumanReadable(LongName = "Jamaica", ShortName = "jm")] - Jamaica, - - [HumanReadable(LongName = "Japan", ShortName = "jp")] - Japan, - - [HumanReadable(LongName = "Jersey", ShortName = "je")] - Jersey, - - [HumanReadable(LongName = "Jordan", ShortName = "jo")] - Jordan, - - #endregion - - #region K - - [HumanReadable(LongName = "Kazakhstan", ShortName = "kz")] - Kazakhstan, - - [HumanReadable(LongName = "Kenya", ShortName = "ke")] - Kenya, - - [HumanReadable(LongName = "Kiribati", ShortName = "ki")] - Kiribati, - - [HumanReadable(LongName = "Korea (Democratic People's Republic of Korea)", ShortName = "kp")] - NorthKorea, - - [HumanReadable(LongName = "Korea (Republic of Korea)", ShortName = "kr")] - SouthKorea, - - [HumanReadable(LongName = "Kuwait", ShortName = "kw")] - Kuwait, - - [HumanReadable(LongName = "Kyrgyzstan", ShortName = "kg")] - Kyrgyzstan, - - #endregion - - #region L - - [HumanReadable(LongName = "(Laos) Lao People's Democratic Republic", ShortName = "la")] - Laos, - - [HumanReadable(LongName = "Latvia", ShortName = "lv")] - Latvia, - - [HumanReadable(LongName = "Lebanon", ShortName = "lb")] - Lebanon, - - [HumanReadable(LongName = "Lesotho", ShortName = "ls")] - Lesotho, - - [HumanReadable(LongName = "Liberia", ShortName = "lr")] - Liberia, - - [HumanReadable(LongName = "Libya", ShortName = "ly")] - Libya, - - [HumanReadable(LongName = "Liechtenstein", ShortName = "li")] - Liechtenstein, - - [HumanReadable(LongName = "Lithuania", ShortName = "lt")] - Lithuania, - - [HumanReadable(LongName = "Luxembourg", ShortName = "lu")] - Luxembourg, - - #endregion - - #region M - - [HumanReadable(LongName = "Macao", ShortName = "mo")] - Macao, - - [HumanReadable(LongName = "Madagascar", ShortName = "mg")] - Madagascar, - - [HumanReadable(LongName = "Malawi", ShortName = "mw")] - Malawi, - - [HumanReadable(LongName = "Malaysia", ShortName = "my")] - Malaysia, - - [HumanReadable(LongName = "Maldives", ShortName = "mv")] - Maldives, - - [HumanReadable(LongName = "Mali", ShortName = "ml")] - Mali, - - [HumanReadable(LongName = "Malta", ShortName = "mt")] - Malta, - - [HumanReadable(LongName = "Marshall Islands", ShortName = "mh")] - MarshallIslands, - - [HumanReadable(LongName = "Martinique", ShortName = "mq")] - Martinique, - - [HumanReadable(LongName = "Mauritania", ShortName = "mr")] - Mauritania, - - [HumanReadable(LongName = "Mauritius", ShortName = "mu")] - Mauritius, - - [HumanReadable(LongName = "Mayotte", ShortName = "yt")] - Mayotte, - - [HumanReadable(LongName = "Mexico", ShortName = "mx")] - Mexico, - - [HumanReadable(LongName = "Monaco", ShortName = "mc")] - Monaco, - - [HumanReadable(LongName = "Mongolia", ShortName = "mn")] - Mongolia, - - [HumanReadable(LongName = "Montenegro", ShortName = "me")] - Montenegro, - - [HumanReadable(LongName = "Montserrat", ShortName = "ms")] - Montserrat, - - [HumanReadable(LongName = "Morocco", ShortName = "ma")] - Morocco, - - [HumanReadable(LongName = "Mozambique", ShortName = "mz")] - Mozambique, - - // Burma was "Bu" - [HumanReadable(LongName = "Myanmar (Burma)", ShortName = "mm")] - Myanmar, - - #endregion - - #region N - - [HumanReadable(LongName = "Namibia", ShortName = "na")] - Namibia, - - [HumanReadable(LongName = "Nauru", ShortName = "nr")] - Nauru, - - [HumanReadable(LongName = "Nepal", ShortName = "np")] - Nepal, - - [HumanReadable(LongName = "Netherlands", ShortName = "nl")] - Netherlands, - - [HumanReadable(LongName = "Netherlands Antilles", ShortName = "an")] - NetherlandsAntilles, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "Neutral Zone", ShortName="nt")] - //NeutralZone, - - [HumanReadable(LongName = "New Caledonia", ShortName = "nc")] - NewCaledonia, - - [HumanReadable(LongName = "New Zealand", ShortName = "nz")] - NewZealand, - - [HumanReadable(LongName = "Nicaragua", ShortName = "ni")] - Nicaragua, - - [HumanReadable(LongName = "Niger", ShortName = "ne")] - Niger, - - [HumanReadable(LongName = "Nigeria", ShortName = "ng")] - Nigeria, - - [HumanReadable(LongName = "Niue", ShortName = "nu")] - Niue, - - [HumanReadable(LongName = "Norfolk Island", ShortName = "nf")] - NorfolkIsland, - - [HumanReadable(LongName = "North Macedonia", ShortName = "mk")] - NorthMacedonia, - - [HumanReadable(LongName = "Northern Mariana Islands", ShortName = "mp")] - NorthernMarianaIslands, - - [HumanReadable(LongName = "Norway", ShortName = "no")] - Norway, - - #endregion - - #region O - - [HumanReadable(LongName = "Oman", ShortName = "om")] - Oman, - - #endregion - - #region P - - [HumanReadable(LongName = "Pakistan", ShortName = "pk")] - Pakistan, - - [HumanReadable(LongName = "Palau", ShortName = "pw")] - Palau, - - [HumanReadable(LongName = "Panama", ShortName = "pa")] - Panama, - - [HumanReadable(LongName = "Papua New Guinea", ShortName = "pg")] - PapuaNewGuinea, - - [HumanReadable(LongName = "Paraguay", ShortName = "py")] - Paraguay, - - [HumanReadable(LongName = "Peru", ShortName = "pe")] - Peru, - - [HumanReadable(LongName = "Philippines", ShortName = "ph")] - Philippines, - - [HumanReadable(LongName = "Pitcairn", ShortName = "pn")] - Pitcairn, - - [HumanReadable(LongName = "Poland", ShortName = "pl")] - Poland, - - [HumanReadable(LongName = "Portugal", ShortName = "pt")] - Portugal, - - [HumanReadable(LongName = "Puerto Rico", ShortName = "pr")] - PuertoRico, - - #endregion - - #region Q - - [HumanReadable(LongName = "Qatar", ShortName = "qa")] - Qatar, - - #endregion - - #region R - - [HumanReadable(LongName = "Republic of Moldova", ShortName = "md")] - RepublicOfMoldova, - - [HumanReadable(LongName = "Réunion", ShortName = "re")] - Reunion, - - [HumanReadable(LongName = "Romania", ShortName = "ro")] - Romania, - - [HumanReadable(LongName = "Russian Federation", ShortName = "ru")] - RussianFederation, - - [HumanReadable(LongName = "Rwanda", ShortName = "rw")] - Rwanda, - - #endregion - - #region S - - [HumanReadable(LongName = "Saint Barthélemy", ShortName = "bl")] - SaintBarthelemy, - - [HumanReadable(LongName = "Saint Helena, Ascension and Tristan da Cunha", ShortName = "sh")] - SaintHelena, - - [HumanReadable(LongName = "Saint Kitts and Nevis", ShortName = "kn")] - SaintKittsAndNevis, - - [HumanReadable(LongName = "Saint Lucia", ShortName = "lc")] - SaintLucia, - - [HumanReadable(LongName = "Saint Martin", ShortName = "mf")] - SaintMartin, - - [HumanReadable(LongName = "Saint Pierre and Miquelon", ShortName = "pm")] - SaintPierreAndMiquelon, - - [HumanReadable(LongName = "Saint Vincent and the Grenadines", ShortName = "vc")] - SaintVincentAndTheGrenadines, - - [HumanReadable(LongName = "Samoa", ShortName = "ws")] - Samoa, - - [HumanReadable(LongName = "San Marino", ShortName = "sm")] - SanMarino, - - [HumanReadable(LongName = "Sao Tome and Principe", ShortName = "st")] - SaoTomeAndPrincipe, - - [HumanReadable(LongName = "Saudi Arabia", ShortName = "sa")] - SaudiArabia, - - [HumanReadable(LongName = "Senegal", ShortName = "sn")] - Senegal, - - [HumanReadable(LongName = "Serbia", ShortName = "rs")] - Serbia, - - [HumanReadable(LongName = "Seychelles", ShortName = "sc")] - Seychelles, - - [HumanReadable(LongName = "Sierra Leone", ShortName = "sl")] - SierraLeone, - - [HumanReadable(LongName = "Singapore", ShortName = "sg")] - Singapore, - - [HumanReadable(LongName = "Sint Maarten", ShortName = "sx")] - SintMaarten, - - [HumanReadable(LongName = "Slovakia", ShortName = "sk")] - Slovakia, - - [HumanReadable(LongName = "Slovenia", ShortName = "si")] - Slovenia, - - [HumanReadable(LongName = "Solomon Islands", ShortName = "sb")] - SolomonIslands, - - [HumanReadable(LongName = "Somalia", ShortName = "so")] - Somalia, - - [HumanReadable(LongName = "South Africa", ShortName = "za")] - SouthAfrica, - - [HumanReadable(LongName = "South Georgia and the South Sandwich Islands", ShortName = "gs")] - SouthGeorgia, - - [HumanReadable(LongName = "South Sudan", ShortName = "ss")] - SouthSudan, - - [HumanReadable(LongName = "Spain", ShortName = "es")] - Spain, - - [HumanReadable(LongName = "Sri Lanka", ShortName = "lk")] - SriLanka, - - [HumanReadable(LongName = "State of Palestine", ShortName = "ps")] - StateOfPalestine, - - [HumanReadable(LongName = "Sudan", ShortName = "sd")] - Sudan, - - [HumanReadable(LongName = "Suriname", ShortName = "sr")] - Suriname, - - [HumanReadable(LongName = "Svalbard and Jan Mayen", ShortName = "sj")] - SvalbardAndJanMayen, - - [HumanReadable(LongName = "Sweden", ShortName = "se")] - Sweden, - - [HumanReadable(LongName = "Switzerland", ShortName = "ch")] - Switzerland, - - [HumanReadable(LongName = "Syrian Arab Republic", ShortName = "sy")] - SyrianArabRepublic, - - #endregion - - #region T - - [HumanReadable(LongName = "Taiwan", ShortName = "tw")] - Taiwan, - - [HumanReadable(LongName = "Tajikistan", ShortName = "tj")] - Tajikistan, - - [HumanReadable(LongName = "Thailand", ShortName = "th")] - Thailand, - - // East Timor was "Tp" - [HumanReadable(LongName = "Timor-Leste (East Timor)", ShortName = "tl")] - TimorLeste, - - [HumanReadable(LongName = "Togo", ShortName = "tg")] - Togo, - - [HumanReadable(LongName = "Tokelau", ShortName = "tk")] - Tokelau, - - [HumanReadable(LongName = "Tonga", ShortName = "to")] - Tonga, - - [HumanReadable(LongName = "Trinidad and Tobago", ShortName = "tt")] - TrinidadAndTobago, - - [HumanReadable(LongName = "Tristan da Cunha", ShortName = "ta")] - TristanDaCunha, - - [HumanReadable(LongName = "Tunisia", ShortName = "tn")] - Tunisia, - - [HumanReadable(LongName = "Turkey", ShortName = "tr")] - Turkey, - - [HumanReadable(LongName = "Turkmenistan", ShortName = "tm")] - Turkmenistan, - - [HumanReadable(LongName = "Turks and Caicos Islands", ShortName = "tc")] - TurksAndCaicosIslands, - - [HumanReadable(LongName = "Tuvalu", ShortName = "tv")] - Tuvalu, - - #endregion - - #region U - - [HumanReadable(LongName = "Uganda", ShortName = "ug")] - Uganda, - - // Should be both "Gb" and "Uk" - // United Kingdom of Great Britain and Northern Ireland - [HumanReadable(LongName = "UK", ShortName = "gb")] - UnitedKingdom, - - [HumanReadable(LongName = "Ukraine", ShortName = "ua")] - Ukraine, - - [HumanReadable(LongName = "United Arab Emirates", ShortName = "ae")] - UnitedArabEmirates, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "United Nations", ShortName="un")] - //UnitedNations, - - [HumanReadable(LongName = "United Republic of Tanzania", ShortName = "tz")] - UnitedRepublicOfTanzania, - - [HumanReadable(LongName = "United States Minor Outlying Islands", ShortName = "um")] - UnitedStatesMinorOutlyingIslands, - - [HumanReadable(LongName = "Uruguay", ShortName = "uy")] - Uruguay, - - // United States of America - [HumanReadable(LongName = "USA", ShortName = "us")] - UnitedStatesOfAmerica, - - [HumanReadable(LongName = "USSR", ShortName = "su")] - USSR, - - [HumanReadable(LongName = "Uzbekistan", ShortName = "uz")] - Uzbekistan, - - #endregion - - #region V - - [HumanReadable(LongName = "Vanuatu", ShortName = "vu")] - Vanuatu, - - [HumanReadable(LongName = "Venezuela", ShortName = "ve")] - Venezuela, - - [HumanReadable(LongName = "Viet Nam", ShortName = "vn")] - VietNam, - - [HumanReadable(LongName = "Virgin Islands (British)", ShortName = "vg")] - BritishVirginIslands, - - [HumanReadable(LongName = "Virgin Islands (US)", ShortName = "vi")] - USVirginIslands, - - #endregion - - #region W - - [HumanReadable(LongName = "Wallis and Futuna", ShortName = "wf")] - WallisAndFutuna, - - [HumanReadable(LongName = "Western Sahara", ShortName = "eh")] - WesternSahara, - - #endregion - - #region Y - - [HumanReadable(LongName = "Yemen", ShortName = "ye")] - Yemen, - - [HumanReadable(LongName = "Yugoslavia", ShortName = "yu")] - Yugoslavia, - - #endregion - - #region Z - - [HumanReadable(LongName = "Zambia", ShortName = "zm")] - Zambia, - - [HumanReadable(LongName = "Zimbabwe", ShortName = "zw")] - Zimbabwe, - - #endregion - } - /// /// List of system categories /// diff --git a/SabreTools.RedumpLib/RedumpInfo/Data/Extensions.cs b/SabreTools.RedumpLib/RedumpInfo/Data/Extensions.cs index 343f8dc..ea591c6 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Data/Extensions.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Data/Extensions.cs @@ -1194,70 +1194,6 @@ namespace SabreTools.RedumpLib.RedumpInfo.Data #endregion - #region Region - - /// - /// Get the Redump longnames for each known region - /// - /// - /// - public static string? LongName(this Region region) - => AttributeHelper.GetHumanReadableAttribute(region)?.LongName; - - /// - /// Get the Redump longnames for each known region - /// - /// - /// - public static string? LongName(this Region? region) - => AttributeHelper.GetHumanReadableAttribute(region)?.LongName; - - /// - /// Get the Redump shortnames for each known region - /// - /// - /// - public static string? ShortName(this Region region) - => AttributeHelper.GetHumanReadableAttribute(region)?.ShortName; - - /// - /// Get the Redump shortnames for each known region - /// - /// - /// - public static string? ShortName(this Region? region) - => AttributeHelper.GetHumanReadableAttribute(region)?.ShortName; - - /// - /// Get the Region enum value for a given string - /// - /// String value to convert - /// Region represented by the string, if possible - public static Region? ToRegion(this string? region) - { - // No value means no match - if (region is null || region.Length == 0) - return null; - - region = region.ToLowerInvariant(); - var redumpSystems = (Region[])Enum.GetValues(typeof(Region)); - - // Check short names - int index = Array.FindIndex(redumpSystems, s => region == s.ShortName()?.ToLowerInvariant()); - if (index > -1) - return redumpSystems[index]; - - // Check long names - index = Array.FindIndex(redumpSystems, s => region == s.LongName()?.ToLowerInvariant() - || region == s.LongName()?.Replace(" ", string.Empty)?.ToLowerInvariant()); - if (index > -1) - return redumpSystems[index]; - - return null; - } - - #endregion - #region System /// diff --git a/SabreTools.RedumpLib/RedumpInfo/Discs.cs b/SabreTools.RedumpLib/RedumpInfo/Discs.cs index 493bc9b..90f7296 100644 --- a/SabreTools.RedumpLib/RedumpInfo/Discs.cs +++ b/SabreTools.RedumpLib/RedumpInfo/Discs.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.RedumpInfo.Data; using SabreTools.RedumpLib.Web; diff --git a/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs b/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs index d873f98..312a0fe 100644 --- a/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs +++ b/SabreTools.RedumpLib/RedumpInfo/UrlBuilder.cs @@ -1,5 +1,6 @@ using System; using System.Text; +using SabreTools.RedumpLib.Data; using SabreTools.RedumpLib.RedumpInfo.Data; using static SabreTools.RedumpLib.RedumpOrg.Data.Extensions; diff --git a/SabreTools.RedumpLib/RedumpOrg/Converters/RegionConverter.cs b/SabreTools.RedumpLib/RedumpOrg/Converters/RegionConverter.cs index 774aa1b..74de992 100644 --- a/SabreTools.RedumpLib/RedumpOrg/Converters/RegionConverter.cs +++ b/SabreTools.RedumpLib/RedumpOrg/Converters/RegionConverter.cs @@ -1,7 +1,7 @@ using System; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SabreTools.RedumpLib.RedumpOrg.Data; +using SabreTools.RedumpLib.Data; namespace SabreTools.RedumpLib.RedumpOrg.Converters { @@ -28,7 +28,7 @@ namespace SabreTools.RedumpLib.RedumpOrg.Converters public override void WriteJson(JsonWriter writer, Region? value, JsonSerializer serializer) { - JToken t = JToken.FromObject(value.ShortName() ?? string.Empty); + JToken t = JToken.FromObject(value.ShortNameAlt() ?? string.Empty); t.WriteTo(writer); } } diff --git a/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs b/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs index 7fe356c..1def2a3 100644 --- a/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs +++ b/SabreTools.RedumpLib/RedumpOrg/Data/Enumerations.cs @@ -811,1040 +811,6 @@ namespace SabreTools.RedumpLib.RedumpOrg.Data #endregion } - /// - /// List of all known regions - /// - /// - /// https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 - /// - /// Because of how Redump stores region IDs, the second letter of each - /// code is lower-cased. In any other system, both letters would be - /// capitalized properly. - /// - public enum Region - { - #region Aggregates - Redump Only - - [HumanReadable(LongName = "Asia", ShortName = "A")] - Asia, - - [HumanReadable(LongName = "Asia, Europe", ShortName = "A,E")] - AsiaEurope, - - [HumanReadable(LongName = "Asia, USA", ShortName = "A,U")] - AsiaUSA, - - [HumanReadable(LongName = "Australia, Germany", ShortName = "Au,G")] - AustraliaGermany, - - [HumanReadable(LongName = "Australia, New Zealand", ShortName = "Au,Nz")] - AustraliaNewZealand, - - [HumanReadable(LongName = "Austria, Switzerland", ShortName = "At,Ch")] - AustriaSwitzerland, - - [HumanReadable(LongName = "Belgium, Netherlands", ShortName = "Be,N")] - BelgiumNetherlands, - - [HumanReadable(LongName = "Europe", ShortName = "E")] - Europe, - - [HumanReadable(LongName = "Europe, Asia", ShortName = "E,A")] - EuropeAsia, - - [HumanReadable(LongName = "Europe, Australia", ShortName = "E,Au")] - EuropeAustralia, - - [HumanReadable(LongName = "Europe, Canada", ShortName = "E,Ca")] - EuropeCanada, - - [HumanReadable(LongName = "Europe, Germany", ShortName = "E,G")] - EuropeGermany, - - [HumanReadable(LongName = "Export", ShortName = "Ex")] - Export, - - [HumanReadable(LongName = "France, Spain", ShortName = "F,S")] - FranceSpain, - - [HumanReadable(LongName = "Greater China", ShortName = "GC")] - GreaterChina, - - [HumanReadable(LongName = "Japan, Asia", ShortName = "J,A")] - JapanAsia, - - [HumanReadable(LongName = "Japan, Europe", ShortName = "J,E")] - JapanEurope, - - [HumanReadable(LongName = "Japan, Korea", ShortName = "J,K")] - JapanKorea, - - [HumanReadable(LongName = "Japan, USA", ShortName = "J,U")] - JapanUSA, - - [HumanReadable(LongName = "Latin America", ShortName = "LAm")] - LatinAmerica, - - [HumanReadable(LongName = "Scandinavia", ShortName = "Sca")] - Scandinavia, - - [HumanReadable(LongName = "Spain, Portugal", ShortName = "S,Pt")] - SpainPortugal, - - [HumanReadable(LongName = "UK, Australia", ShortName = "Uk,Au")] - UKAustralia, - - [HumanReadable(LongName = "USA, Asia", ShortName = "U,A")] - USAAsia, - - [HumanReadable(LongName = "USA, Australia", ShortName = "U,Au")] - USAAustralia, - - [HumanReadable(LongName = "USA, Brazil", ShortName = "U,B")] - USABrazil, - - [HumanReadable(LongName = "USA, Canada", ShortName = "U,Ca")] - USACanada, - - [HumanReadable(LongName = "USA, Europe", ShortName = "U,E")] - USAEurope, - - [HumanReadable(LongName = "USA, Germany", ShortName = "U,G")] - USAGermany, - - [HumanReadable(LongName = "USA, Japan", ShortName = "U,J")] - USAJapan, - - [HumanReadable(LongName = "USA, Korea", ShortName = "U,K")] - USAKorea, - - [HumanReadable(LongName = "World", ShortName = "W")] - World, - - #endregion - - #region A - - [HumanReadable(LongName = "Afghanistan", ShortName = "Af")] - Afghanistan, - - [HumanReadable(LongName = "Åland Islands", ShortName = "Ax")] - AlandIslands, - - [HumanReadable(LongName = "Albania", ShortName = "Al")] - Albania, - - [HumanReadable(LongName = "Algeria", ShortName = "Dz")] - Algeria, - - [HumanReadable(LongName = "American Samoa", ShortName = "As")] - AmericanSamoa, - - [HumanReadable(LongName = "Andorra", ShortName = "Ad")] - Andorra, - - [HumanReadable(LongName = "Angola", ShortName = "Ao")] - Angola, - - [HumanReadable(LongName = "Anguilla", ShortName = "Ai")] - Anguilla, - - [HumanReadable(LongName = "Antarctica", ShortName = "Aq")] - Antarctica, - - [HumanReadable(LongName = "Antigua and Barbuda", ShortName = "Ag")] - AntiguaAndBarbuda, - - [HumanReadable(LongName = "Argentina", ShortName = "Ar")] - Argentina, - - [HumanReadable(LongName = "Armenia", ShortName = "Am")] - Armenia, - - [HumanReadable(LongName = "Aruba", ShortName = "Aw")] - Aruba, - - [HumanReadable(LongName = "Ascension Island", ShortName = "Ac")] - AscensionIsland, - - [HumanReadable(LongName = "Australia", ShortName = "Au")] - Australia, - - [HumanReadable(LongName = "Austria", ShortName = "At")] - Austria, - - [HumanReadable(LongName = "Azerbaijan", ShortName = "Az")] - Azerbaijan, - - #endregion - - #region B - - [HumanReadable(LongName = "Bahamas", ShortName = "Bs")] - Bahamas, - - [HumanReadable(LongName = "Bahrain", ShortName = "Bh")] - Bahrain, - - [HumanReadable(LongName = "Bangladesh", ShortName = "Bd")] - Bangladesh, - - [HumanReadable(LongName = "Barbados", ShortName = "Bb")] - Barbados, - - [HumanReadable(LongName = "Belarus", ShortName = "By")] - Belarus, - - [HumanReadable(LongName = "Belgium", ShortName = "Be")] - Belgium, - - [HumanReadable(LongName = "Belize", ShortName = "Bz")] - Belize, - - [HumanReadable(LongName = "Benin", ShortName = "Bj")] - Benin, - - [HumanReadable(LongName = "Bermuda", ShortName = "Bm")] - Bermuda, - - [HumanReadable(LongName = "Bhutan", ShortName = "Bt")] - Bhutan, - - [HumanReadable(LongName = "Bolivia", ShortName = "Bo")] - Bolivia, - - [HumanReadable(LongName = "Bonaire, Sint Eustatius and Saba", ShortName = "Bq")] - Bonaire, - - [HumanReadable(LongName = "Bosnia and Herzegovina", ShortName = "Ba")] - BosniaAndHerzegovina, - - [HumanReadable(LongName = "Botswana", ShortName = "Bw")] - Botswana, - - [HumanReadable(LongName = "Bouvet Island", ShortName = "Bv")] - BouvetIsland, - - // Should be "Br" - [HumanReadable(LongName = "Brazil", ShortName = "B")] - Brazil, - - [HumanReadable(LongName = "British Indian Ocean Territory", ShortName = "Io")] - BritishIndianOceanTerritory, - - [HumanReadable(LongName = "Brunei Darussalam", ShortName = "Bn")] - BruneiDarussalam, - - [HumanReadable(LongName = "Bulgaria", ShortName = "Bg")] - Bulgaria, - - [HumanReadable(LongName = "Burkina Faso", ShortName = "Bf")] - BurkinaFaso, - - [HumanReadable(LongName = "Burundi", ShortName = "Bi")] - Burundi, - - #endregion - - #region C - - [HumanReadable(LongName = "Cabo Verde", ShortName = "Cv")] - CaboVerde, - - [HumanReadable(LongName = "Cambodia", ShortName = "Kh")] - Cambodia, - - [HumanReadable(LongName = "Cameroon", ShortName = "Cm")] - Cameroon, - - [HumanReadable(LongName = "Canada", ShortName = "Ca")] - Canada, - - [HumanReadable(LongName = "Canary Islands", ShortName = "Ic")] - CanaryIslands, - - [HumanReadable(LongName = "Cayman Islands", ShortName = "Ky")] - CaymanIslands, - - [HumanReadable(LongName = "Central African Republic", ShortName = "Cf")] - CentralAfricanRepublic, - - [HumanReadable(LongName = "Ceuta, Melilla", ShortName = "Ea")] - CeutaMelilla, - - [HumanReadable(LongName = "Chad", ShortName = "Td")] - Chad, - - [HumanReadable(LongName = "Chile", ShortName = "Cl")] - Chile, - - // Should be "Cn" - [HumanReadable(LongName = "China", ShortName = "C")] - China, - - [HumanReadable(LongName = "Christmas Island", ShortName = "Cx")] - ChristmasIsland, - - [HumanReadable(LongName = "Clipperton Island", ShortName = "Cp")] - ClippertonIsland, - - [HumanReadable(LongName = "Cocos (Keeling) Islands", ShortName = "Cc")] - CocosIslands, - - [HumanReadable(LongName = "Colombia", ShortName = "Co")] - Colombia, - - [HumanReadable(LongName = "Comoros", ShortName = "Km")] - Comoros, - - [HumanReadable(LongName = "Congo", ShortName = "Cg")] - Congo, - - [HumanReadable(LongName = "Cook Islands", ShortName = "Ck")] - CookIslands, - - [HumanReadable(LongName = "Costa Rica", ShortName = "Cr")] - CostaRica, - - [HumanReadable(LongName = "Côte d'Ivoire", ShortName = "Ci")] - CoteDIvoire, - - [HumanReadable(LongName = "Croatia", ShortName = "Hr")] - Croatia, - - [HumanReadable(LongName = "Cuba", ShortName = "Cu")] - Cuba, - - [HumanReadable(LongName = "Curaçao", ShortName = "Cw")] - Curacao, - - [HumanReadable(LongName = "Cyprus", ShortName = "Cy")] - Cyprus, - - [HumanReadable(LongName = "Czechia", ShortName = "Cz")] - Czechia, - - [HumanReadable(LongName = "Czechoslovakia", ShortName = "Cs")] - Czechoslovakia, - - #endregion - - #region D - - // Zaire was "Zr" - [HumanReadable(LongName = "Democratic Republic of the Congo (Zaire)", ShortName = "Cd")] - DemocraticRepublicOfTheCongo, - - [HumanReadable(LongName = "Denmark", ShortName = "Dk")] - Denmark, - - [HumanReadable(LongName = "Diego Garcia", ShortName = "Dg")] - DiegoGarcia, - - [HumanReadable(LongName = "Djibouti", ShortName = "Dj")] - Djibouti, - - [HumanReadable(LongName = "Dominica", ShortName = "Dm")] - Dominica, - - [HumanReadable(LongName = "Dominican Republic", ShortName = "Do")] - DominicanRepublic, - - #endregion - - #region E - - [HumanReadable(LongName = "Ecuador", ShortName = "Ec")] - Ecuador, - - [HumanReadable(LongName = "Egypt", ShortName = "Eg")] - Egypt, - - [HumanReadable(LongName = "El Salvador", ShortName = "Sv")] - ElSalvador, - - [HumanReadable(LongName = "Equatorial Guinea", ShortName = "Gq")] - EquatorialGuinea, - - [HumanReadable(LongName = "Eritrea", ShortName = "Er")] - Eritrea, - - [HumanReadable(LongName = "Estonia", ShortName = "Ee")] - Estonia, - - [HumanReadable(LongName = "Eswatini", ShortName = "Sz")] - Eswatini, - - [HumanReadable(LongName = "Ethiopia", ShortName = "Et")] - Ethiopia, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "European Union", ShortName = "Eu")] - //EuropeanUnion, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "Eurozone", ShortName = "Ez")] - //Eurozone, - - #endregion - - #region F - - [HumanReadable(LongName = "Falkland Islands (Malvinas)", ShortName = "Fk")] - FalklandIslands, - - [HumanReadable(LongName = "Faroe Islands", ShortName = "Fo")] - FaroeIslands, - - [HumanReadable(LongName = "Federated States of Micronesia", ShortName = "Fm")] - FederatedStatesOfMicronesia, - - [HumanReadable(LongName = "Fiji", ShortName = "Fj")] - Fiji, - - // Formerly "Sf" - [HumanReadable(LongName = "Finland", ShortName = "Fi")] - Finland, - - // Should be "Fr" - [HumanReadable(LongName = "France", ShortName = "F")] - France, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "France, Metropolitan", ShortName = "Fx")] - //FranceMetropolitan, - - [HumanReadable(LongName = "French Guiana", ShortName = "Gf")] - FrenchGuiana, - - [HumanReadable(LongName = "French Polynesia", ShortName = "Pf")] - FrenchPolynesia, - - [HumanReadable(LongName = "French Southern Territories", ShortName = "Tf")] - FrenchSouthernTerritories, - - #endregion - - #region G - - [HumanReadable(LongName = "Gabon", ShortName = "Ga")] - Gabon, - - [HumanReadable(LongName = "Gambia", ShortName = "Gm")] - Gambia, - - [HumanReadable(LongName = "Georgia", ShortName = "Ge")] - Georgia, - - // Should be "De" - [HumanReadable(LongName = "Germany", ShortName = "G")] - Germany, - - [HumanReadable(LongName = "Ghana", ShortName = "Gh")] - Ghana, - - [HumanReadable(LongName = "Gibraltar", ShortName = "Gi")] - Gibraltar, - - [HumanReadable(LongName = "Greece", ShortName = "Gr")] - Greece, - - [HumanReadable(LongName = "Greenland", ShortName = "Gl")] - Greenland, - - [HumanReadable(LongName = "Grenada", ShortName = "Gd")] - Grenada, - - [HumanReadable(LongName = "Guadeloupe", ShortName = "Gp")] - Guadeloupe, - - [HumanReadable(LongName = "Guam", ShortName = "Gu")] - Guam, - - [HumanReadable(LongName = "Guatemala", ShortName = "Gt")] - Guatemala, - - [HumanReadable(LongName = "Guernsey", ShortName = "Gg")] - Guernsey, - - [HumanReadable(LongName = "Guinea", ShortName = "Gn")] - Guinea, - - [HumanReadable(LongName = "Guinea-Bissau", ShortName = "Gw")] - GuineaBissau, - - [HumanReadable(LongName = "Guyana", ShortName = "Gy")] - Guyana, - - #endregion - - #region H - - [HumanReadable(LongName = "Haiti", ShortName = "Ht")] - Haiti, - - [HumanReadable(LongName = "Heard Island and McDonald Islands", ShortName = "Hm")] - HeardIslandAndMcDonaldIslands, - - [HumanReadable(LongName = "Holy See (Vatican City)", ShortName = "Va")] - HolySee, - - [HumanReadable(LongName = "Honduras", ShortName = "Hn")] - Honduras, - - [HumanReadable(LongName = "Hong Kong", ShortName = "Hk")] - HongKong, - - // Should be "Hu" - [HumanReadable(LongName = "Hungary", ShortName = "H")] - Hungary, - - #endregion - - #region I - - [HumanReadable(LongName = "Iceland", ShortName = "Is")] - Iceland, - - [HumanReadable(LongName = "India", ShortName = "In")] - India, - - [HumanReadable(LongName = "Indonesia", ShortName = "Id")] - Indonesia, - - [HumanReadable(LongName = "Iran", ShortName = "Ir")] - Iran, - - [HumanReadable(LongName = "Iraq", ShortName = "Iq")] - Iraq, - - [HumanReadable(LongName = "Ireland", ShortName = "Ie")] - Ireland, - - [HumanReadable(LongName = "Island of Sark", ShortName = "Cq")] - IslandOfSark, - - [HumanReadable(LongName = "Isle of Man", ShortName = "Im")] - IsleOfMan, - - [HumanReadable(LongName = "Israel", ShortName = "Il")] - Israel, - - // Should be "It" - [HumanReadable(LongName = "Italy", ShortName = "I")] - Italy, - - #endregion - - #region J - - [HumanReadable(LongName = "Jamaica", ShortName = "Jm")] - Jamaica, - - // Should be "Jp" - [HumanReadable(LongName = "Japan", ShortName = "J")] - Japan, - - [HumanReadable(LongName = "Jersey", ShortName = "Je")] - Jersey, - - [HumanReadable(LongName = "Jordan", ShortName = "Jo")] - Jordan, - - #endregion - - #region K - - [HumanReadable(LongName = "Kazakhstan", ShortName = "Kz")] - Kazakhstan, - - [HumanReadable(LongName = "Kenya", ShortName = "Ke")] - Kenya, - - [HumanReadable(LongName = "Kiribati", ShortName = "Ki")] - Kiribati, - - [HumanReadable(LongName = "Korea (Democratic People's Republic of Korea)", ShortName = "Kp")] - NorthKorea, - - // Should be "Kr" - [HumanReadable(LongName = "Korea (Republic of Korea)", ShortName = "K")] - SouthKorea, - - [HumanReadable(LongName = "Kuwait", ShortName = "Kw")] - Kuwait, - - [HumanReadable(LongName = "Kyrgyzstan", ShortName = "Kg")] - Kyrgyzstan, - - #endregion - - #region L - - [HumanReadable(LongName = "(Laos) Lao People's Democratic Republic", ShortName = "La")] - Laos, - - [HumanReadable(LongName = "Latvia", ShortName = "Lv")] - Latvia, - - [HumanReadable(LongName = "Lebanon", ShortName = "Lb")] - Lebanon, - - [HumanReadable(LongName = "Lesotho", ShortName = "Ls")] - Lesotho, - - [HumanReadable(LongName = "Liberia", ShortName = "Lr")] - Liberia, - - [HumanReadable(LongName = "Libya", ShortName = "Ly")] - Libya, - - [HumanReadable(LongName = "Liechtenstein", ShortName = "Li")] - Liechtenstein, - - [HumanReadable(LongName = "Lithuania", ShortName = "Lt")] - Lithuania, - - [HumanReadable(LongName = "Luxembourg", ShortName = "Lu")] - Luxembourg, - - #endregion - - #region M - - [HumanReadable(LongName = "Macao", ShortName = "Mo")] - Macao, - - [HumanReadable(LongName = "Madagascar", ShortName = "Mg")] - Madagascar, - - [HumanReadable(LongName = "Malawi", ShortName = "Mw")] - Malawi, - - [HumanReadable(LongName = "Malaysia", ShortName = "My")] - Malaysia, - - [HumanReadable(LongName = "Maldives", ShortName = "Mv")] - Maldives, - - [HumanReadable(LongName = "Mali", ShortName = "Ml")] - Mali, - - [HumanReadable(LongName = "Malta", ShortName = "Mt")] - Malta, - - [HumanReadable(LongName = "Marshall Islands", ShortName = "Mh")] - MarshallIslands, - - [HumanReadable(LongName = "Martinique", ShortName = "Mq")] - Martinique, - - [HumanReadable(LongName = "Mauritania", ShortName = "Mr")] - Mauritania, - - [HumanReadable(LongName = "Mauritius", ShortName = "Mu")] - Mauritius, - - [HumanReadable(LongName = "Mayotte", ShortName = "Yt")] - Mayotte, - - [HumanReadable(LongName = "Mexico", ShortName = "Mx")] - Mexico, - - [HumanReadable(LongName = "Monaco", ShortName = "Mc")] - Monaco, - - [HumanReadable(LongName = "Mongolia", ShortName = "Mn")] - Mongolia, - - [HumanReadable(LongName = "Montenegro", ShortName = "Me")] - Montenegro, - - [HumanReadable(LongName = "Montserrat", ShortName = "Ms")] - Montserrat, - - [HumanReadable(LongName = "Morocco", ShortName = "Ma")] - Morocco, - - [HumanReadable(LongName = "Mozambique", ShortName = "Mz")] - Mozambique, - - // Burma was "Bu" - [HumanReadable(LongName = "Myanmar (Burma)", ShortName = "Mm")] - Myanmar, - - #endregion - - #region N - - [HumanReadable(LongName = "Namibia", ShortName = "Na")] - Namibia, - - [HumanReadable(LongName = "Nauru", ShortName = "Nr")] - Nauru, - - [HumanReadable(LongName = "Nepal", ShortName = "Np")] - Nepal, - - // Should be "Nl" - [HumanReadable(LongName = "Netherlands", ShortName = "N")] - Netherlands, - - [HumanReadable(LongName = "Netherlands Antilles", ShortName = "An")] - NetherlandsAntilles, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "Neutral Zone", ShortName = "Nt")] - //NeutralZone, - - [HumanReadable(LongName = "New Caledonia", ShortName = "Nc")] - NewCaledonia, - - [HumanReadable(LongName = "New Zealand", ShortName = "Nz")] - NewZealand, - - [HumanReadable(LongName = "Nicaragua", ShortName = "Ni")] - Nicaragua, - - [HumanReadable(LongName = "Niger", ShortName = "Ne")] - Niger, - - [HumanReadable(LongName = "Nigeria", ShortName = "Ng")] - Nigeria, - - [HumanReadable(LongName = "Niue", ShortName = "Nu")] - Niue, - - [HumanReadable(LongName = "Norfolk Island", ShortName = "Nf")] - NorfolkIsland, - - [HumanReadable(LongName = "North Macedonia", ShortName = "Mk")] - NorthMacedonia, - - [HumanReadable(LongName = "Northern Mariana Islands", ShortName = "Mp")] - NorthernMarianaIslands, - - [HumanReadable(LongName = "Norway", ShortName = "No")] - Norway, - - #endregion - - #region O - - [HumanReadable(LongName = "Oman", ShortName = "Om")] - Oman, - - #endregion - - #region P - - [HumanReadable(LongName = "Pakistan", ShortName = "Pk")] - Pakistan, - - [HumanReadable(LongName = "Palau", ShortName = "Pw")] - Palau, - - [HumanReadable(LongName = "Panama", ShortName = "Pa")] - Panama, - - [HumanReadable(LongName = "Papua New Guinea", ShortName = "Pg")] - PapuaNewGuinea, - - [HumanReadable(LongName = "Paraguay", ShortName = "Py")] - Paraguay, - - [HumanReadable(LongName = "Peru", ShortName = "Pe")] - Peru, - - [HumanReadable(LongName = "Philippines", ShortName = "Ph")] - Philippines, - - [HumanReadable(LongName = "Pitcairn", ShortName = "Pn")] - Pitcairn, - - // Should be "Pl" - [HumanReadable(LongName = "Poland", ShortName = "P")] - Poland, - - [HumanReadable(LongName = "Portugal", ShortName = "Pt")] - Portugal, - - [HumanReadable(LongName = "Puerto Rico", ShortName = "Pr")] - PuertoRico, - - #endregion - - #region Q - - [HumanReadable(LongName = "Qatar", ShortName = "Qa")] - Qatar, - - #endregion - - #region R - - [HumanReadable(LongName = "Republic of Moldova", ShortName = "Md")] - RepublicOfMoldova, - - [HumanReadable(LongName = "Réunion", ShortName = "Re")] - Reunion, - - [HumanReadable(LongName = "Romania", ShortName = "Ro")] - Romania, - - // Should be "Ru" - [HumanReadable(LongName = "Russian Federation", ShortName = "R")] - RussianFederation, - - [HumanReadable(LongName = "Rwanda", ShortName = "Rw")] - Rwanda, - - #endregion - - #region S - - [HumanReadable(LongName = "Saint Barthélemy", ShortName = "Bl")] - SaintBarthelemy, - - [HumanReadable(LongName = "Saint Helena, Ascension and Tristan da Cunha", ShortName = "Sh")] - SaintHelena, - - [HumanReadable(LongName = "Saint Kitts and Nevis", ShortName = "Kn")] - SaintKittsAndNevis, - - [HumanReadable(LongName = "Saint Lucia", ShortName = "Lc")] - SaintLucia, - - [HumanReadable(LongName = "Saint Martin", ShortName = "Mf")] - SaintMartin, - - [HumanReadable(LongName = "Saint Pierre and Miquelon", ShortName = "Pm")] - SaintPierreAndMiquelon, - - [HumanReadable(LongName = "Saint Vincent and the Grenadines", ShortName = "Vc")] - SaintVincentAndTheGrenadines, - - [HumanReadable(LongName = "Samoa", ShortName = "Ws")] - Samoa, - - [HumanReadable(LongName = "San Marino", ShortName = "Sm")] - SanMarino, - - [HumanReadable(LongName = "Sao Tome and Principe", ShortName = "St")] - SaoTomeAndPrincipe, - - [HumanReadable(LongName = "Saudi Arabia", ShortName = "Sa")] - SaudiArabia, - - [HumanReadable(LongName = "Senegal", ShortName = "Sn")] - Senegal, - - [HumanReadable(LongName = "Serbia", ShortName = "Rs")] - Serbia, - - [HumanReadable(LongName = "Seychelles", ShortName = "Sc")] - Seychelles, - - [HumanReadable(LongName = "Sierra Leone", ShortName = "Sl")] - SierraLeone, - - [HumanReadable(LongName = "Singapore", ShortName = "Sg")] - Singapore, - - [HumanReadable(LongName = "Sint Maarten", ShortName = "Sx")] - SintMaarten, - - [HumanReadable(LongName = "Slovakia", ShortName = "Sk")] - Slovakia, - - [HumanReadable(LongName = "Slovenia", ShortName = "Si")] - Slovenia, - - [HumanReadable(LongName = "Solomon Islands", ShortName = "Sb")] - SolomonIslands, - - [HumanReadable(LongName = "Somalia", ShortName = "So")] - Somalia, - - [HumanReadable(LongName = "South Africa", ShortName = "Za")] - SouthAfrica, - - [HumanReadable(LongName = "South Georgia and the South Sandwich Islands", ShortName = "Gs")] - SouthGeorgia, - - [HumanReadable(LongName = "South Sudan", ShortName = "Ss")] - SouthSudan, - - // Should be "Es" - [HumanReadable(LongName = "Spain", ShortName = "S")] - Spain, - - [HumanReadable(LongName = "Sri Lanka", ShortName = "Lk")] - SriLanka, - - [HumanReadable(LongName = "State of Palestine", ShortName = "Ps")] - StateOfPalestine, - - [HumanReadable(LongName = "Sudan", ShortName = "Sd")] - Sudan, - - [HumanReadable(LongName = "Suriname", ShortName = "Sr")] - Suriname, - - [HumanReadable(LongName = "Svalbard and Jan Mayen", ShortName = "Sj")] - SvalbardAndJanMayen, - - // Should be "Se" - [HumanReadable(LongName = "Sweden", ShortName = "Sw")] - Sweden, - - [HumanReadable(LongName = "Switzerland", ShortName = "Ch")] - Switzerland, - - [HumanReadable(LongName = "Syrian Arab Republic", ShortName = "Sy")] - SyrianArabRepublic, - - #endregion - - #region T - - [HumanReadable(LongName = "Taiwan", ShortName = "Tw")] - Taiwan, - - [HumanReadable(LongName = "Tajikistan", ShortName = "Tj")] - Tajikistan, - - [HumanReadable(LongName = "Thailand", ShortName = "Th")] - Thailand, - - // East Timor was "Tp" - [HumanReadable(LongName = "Timor-Leste (East Timor)", ShortName = "Tl")] - TimorLeste, - - [HumanReadable(LongName = "Togo", ShortName = "Tg")] - Togo, - - [HumanReadable(LongName = "Tokelau", ShortName = "Tk")] - Tokelau, - - [HumanReadable(LongName = "Tonga", ShortName = "To")] - Tonga, - - [HumanReadable(LongName = "Trinidad and Tobago", ShortName = "Tt")] - TrinidadAndTobago, - - [HumanReadable(LongName = "Tristan da Cunha", ShortName = "Ta")] - TristanDaCunha, - - [HumanReadable(LongName = "Tunisia", ShortName = "Tn")] - Tunisia, - - [HumanReadable(LongName = "Turkey", ShortName = "Tr")] - Turkey, - - [HumanReadable(LongName = "Turkmenistan", ShortName = "Tm")] - Turkmenistan, - - [HumanReadable(LongName = "Turks and Caicos Islands", ShortName = "Tc")] - TurksAndCaicosIslands, - - [HumanReadable(LongName = "Tuvalu", ShortName = "Tv")] - Tuvalu, - - #endregion - - #region U - - [HumanReadable(LongName = "Uganda", ShortName = "Ug")] - Uganda, - - // Should be both "Gb" and "Uk" - // United Kingdom of Great Britain and Northern Ireland - [HumanReadable(LongName = "UK", ShortName = "Uk")] - UnitedKingdom, - - [HumanReadable(LongName = "Ukraine", ShortName = "Ue")] - Ukraine, - - [HumanReadable(LongName = "United Arab Emirates", ShortName = "Ae")] - UnitedArabEmirates, - - // Commented out to avoid confusion - //[HumanReadable(LongName = "United Nations", ShortName = "Un")] - //UnitedNations, - - [HumanReadable(LongName = "United Republic of Tanzania", ShortName = "Tz")] - UnitedRepublicOfTanzania, - - [HumanReadable(LongName = "United States Minor Outlying Islands", ShortName = "Um")] - UnitedStatesMinorOutlyingIslands, - - [HumanReadable(LongName = "Uruguay", ShortName = "Uy")] - Uruguay, - - // Should be "Us" - // United States of America - [HumanReadable(LongName = "USA", ShortName = "U")] - UnitedStatesOfAmerica, - - [HumanReadable(LongName = "USSR", ShortName = "Su")] - USSR, - - [HumanReadable(LongName = "Uzbekistan", ShortName = "Uz")] - Uzbekistan, - - #endregion - - #region V - - [HumanReadable(LongName = "Vanuatu", ShortName = "Vu")] - Vanuatu, - - [HumanReadable(LongName = "Venezuela", ShortName = "Ve")] - Venezuela, - - [HumanReadable(LongName = "Viet Nam", ShortName = "Vn")] - VietNam, - - [HumanReadable(LongName = "Virgin Islands (British)", ShortName = "Vg")] - BritishVirginIslands, - - [HumanReadable(LongName = "Virgin Islands (US)", ShortName = "Vi")] - USVirginIslands, - - #endregion - - #region W - - [HumanReadable(LongName = "Wallis and Futuna", ShortName = "Wf")] - WallisAndFutuna, - - [HumanReadable(LongName = "Western Sahara", ShortName = "Eh")] - WesternSahara, - - #endregion - - #region Y - - [HumanReadable(LongName = "Yemen", ShortName = "Ye")] - Yemen, - - [HumanReadable(LongName = "Yugoslavia", ShortName = "Yu")] - Yugoslavia, - - #endregion - - #region Z - - [HumanReadable(LongName = "Zambia", ShortName = "Zm")] - Zambia, - - [HumanReadable(LongName = "Zimbabwe", ShortName = "Zw")] - Zimbabwe, - - #endregion - } - /// /// List of all Redump site codes /// diff --git a/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs b/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs index dc713a8..61ecb73 100644 --- a/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs +++ b/SabreTools.RedumpLib/RedumpOrg/Data/Extensions.cs @@ -1179,70 +1179,6 @@ namespace SabreTools.RedumpLib.RedumpOrg.Data #endregion - #region Region - - /// - /// Get the Redump longnames for each known region - /// - /// - /// - public static string? LongName(this Region region) - => AttributeHelper.GetHumanReadableAttribute(region)?.LongName; - - /// - /// Get the Redump longnames for each known region - /// - /// - /// - public static string? LongName(this Region? region) - => AttributeHelper.GetHumanReadableAttribute(region)?.LongName; - - /// - /// Get the Redump shortnames for each known region - /// - /// - /// - public static string? ShortName(this Region region) - => AttributeHelper.GetHumanReadableAttribute(region)?.ShortName; - - /// - /// Get the Redump shortnames for each known region - /// - /// - /// - public static string? ShortName(this Region? region) - => AttributeHelper.GetHumanReadableAttribute(region)?.ShortName; - - /// - /// Get the Region enum value for a given string - /// - /// String value to convert - /// Region represented by the string, if possible - public static Region? ToRegion(this string? region) - { - // No value means no match - if (region is null || region.Length == 0) - return null; - - region = region.ToLowerInvariant(); - var redumpSystems = (Region[])Enum.GetValues(typeof(Region)); - - // Check short names - int index = Array.FindIndex(redumpSystems, s => region == s.ShortName()?.ToLowerInvariant()); - if (index > -1) - return redumpSystems[index]; - - // Check long names - index = Array.FindIndex(redumpSystems, s => region == s.LongName()?.ToLowerInvariant() - || region == s.LongName()?.Replace(" ", string.Empty)?.ToLowerInvariant()); - if (index > -1) - return redumpSystems[index]; - - return null; - } - - #endregion - #region Site Code ///