mirror of
https://github.com/SabreTools/SabreTools.RedumpLib.git
synced 2026-09-23 23:45:01 +00:00
Enable latest language version
This commit is contained in:
@@ -10,11 +10,7 @@ namespace SabreTools.RedumpLib.Attributes
|
||||
/// </summary>
|
||||
/// <param name="value">Value to use</param>
|
||||
/// <returns>HumanReadableAttribute attached to the value</returns>
|
||||
#if NET48
|
||||
public static HumanReadableAttribute GetAttribute(T value)
|
||||
#else
|
||||
public static HumanReadableAttribute? GetAttribute(T value)
|
||||
#endif
|
||||
{
|
||||
// Null value in, null value out
|
||||
if (value == null)
|
||||
@@ -26,11 +22,7 @@ namespace SabreTools.RedumpLib.Attributes
|
||||
enumType = Nullable.GetUnderlyingType(enumType);
|
||||
|
||||
// If the value returns a null on ToString, just return null
|
||||
#if NET48
|
||||
string valueStr = value?.ToString();
|
||||
#else
|
||||
string? valueStr = value?.ToString();
|
||||
#endif
|
||||
if (string.IsNullOrWhiteSpace(valueStr))
|
||||
return null;
|
||||
|
||||
|
||||
@@ -15,19 +15,11 @@ namespace SabreTools.RedumpLib.Attributes
|
||||
/// <summary>
|
||||
/// Human-readable name of the item
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string LongName { get; set; }
|
||||
#else
|
||||
public string? LongName { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Internally used name of the item
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string ShortName { get; set; }
|
||||
#else
|
||||
public string? ShortName { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -11,28 +11,16 @@ namespace SabreTools.RedumpLib.Attributes
|
||||
/// <summary>
|
||||
/// ISO 639-1 Code
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string TwoLetterCode { get; set; } = null;
|
||||
#else
|
||||
public string? TwoLetterCode { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// ISO 639-2 Code (Standard or Bibliographic)
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string ThreeLetterCode { get; set; } = null;
|
||||
#else
|
||||
public string? ThreeLetterCode { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// ISO 639-2 Code (Terminology)
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string ThreeLetterCodeAlt { get; set; } = null;
|
||||
#else
|
||||
public string? ThreeLetterCodeAlt { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -12,20 +12,12 @@ namespace SabreTools.RedumpLib.Converters
|
||||
{
|
||||
public override bool CanRead { get { return false; } }
|
||||
|
||||
#if NET48
|
||||
public override Language?[] ReadJson(JsonReader reader, Type objectType, Language?[] existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
#else
|
||||
public override Language?[] ReadJson(JsonReader reader, Type objectType, Language?[]? existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
#endif
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
public override void WriteJson(JsonWriter writer, Language?[] value, JsonSerializer serializer)
|
||||
#else
|
||||
public override void WriteJson(JsonWriter writer, Language?[]? value, JsonSerializer serializer)
|
||||
#endif
|
||||
{
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
@@ -12,20 +12,12 @@ namespace SabreTools.RedumpLib.Converters
|
||||
{
|
||||
public override bool CanRead { get { return false; } }
|
||||
|
||||
#if NET48
|
||||
public override LanguageSelection?[] ReadJson(JsonReader reader, Type objectType, LanguageSelection?[] existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
#else
|
||||
public override LanguageSelection?[] ReadJson(JsonReader reader, Type objectType, LanguageSelection?[]? existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
#endif
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#if NET48
|
||||
public override void WriteJson(JsonWriter writer, LanguageSelection?[] value, JsonSerializer serializer)
|
||||
#else
|
||||
public override void WriteJson(JsonWriter writer, LanguageSelection?[]? value, JsonSerializer serializer)
|
||||
#endif
|
||||
{
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
@@ -812,11 +812,7 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string LongName(this DiscCategory? category) => AttributeHelper<DiscCategory?>.GetAttribute(category)?.LongName;
|
||||
#else
|
||||
public static string? LongName(this DiscCategory? category) => AttributeHelper<DiscCategory?>.GetAttribute(category)?.LongName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the Category enum value for a given string
|
||||
@@ -865,11 +861,7 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="discType"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string LongName(this DiscType? discType) => AttributeHelper<DiscType?>.GetAttribute(discType)?.LongName;
|
||||
#else
|
||||
public static string? LongName(this DiscType? discType) => AttributeHelper<DiscType?>.GetAttribute(discType)?.LongName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the DiscType enum value for a given string
|
||||
@@ -955,22 +947,14 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string LongName(this Language? language) => AttributeHelper<Language?>.GetAttribute(language)?.LongName;
|
||||
#else
|
||||
public static string? LongName(this Language? language) => AttributeHelper<Language?>.GetAttribute(language)?.LongName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the Redump shortnames for each known language
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string ShortName(this Language? language)
|
||||
#else
|
||||
public static string? ShortName(this Language? language)
|
||||
#endif
|
||||
{
|
||||
// Some languages need to use the alternate code instead
|
||||
switch (language)
|
||||
@@ -1029,33 +1013,21 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string ThreeLetterCode(this Language? language) => ((LanguageAttribute)AttributeHelper<Language?>.GetAttribute(language))?.ThreeLetterCode;
|
||||
#else
|
||||
public static string? ThreeLetterCode(this Language? language) => (AttributeHelper<Language?>.GetAttribute(language) as LanguageAttribute)?.ThreeLetterCode;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the ISO 639-2 alternate code for each known language
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string ThreeLetterCodeAlt(this Language? language) => ((LanguageAttribute)AttributeHelper<Language?>.GetAttribute(language))?.ThreeLetterCodeAlt;
|
||||
#else
|
||||
public static string? ThreeLetterCodeAlt(this Language? language) => (AttributeHelper<Language?>.GetAttribute(language) as LanguageAttribute)?.ThreeLetterCodeAlt;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the ISO 639-1 code for each known language
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string TwoLetterCode(this Language? language) => ((LanguageAttribute)AttributeHelper<Language?>.GetAttribute(language))?.TwoLetterCode;
|
||||
#else
|
||||
public static string? TwoLetterCode(this Language? language) => (AttributeHelper<Language?>.GetAttribute(language) as LanguageAttribute)?.TwoLetterCode;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1066,11 +1038,7 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="langSelect">LanguageSelection value to convert</param>
|
||||
/// <returns>String representing the value, if possible</returns>
|
||||
#if NET48
|
||||
public static string LongName(this LanguageSelection? langSelect) => AttributeHelper<LanguageSelection?>.GetAttribute(langSelect)?.LongName;
|
||||
#else
|
||||
public static string? LongName(this LanguageSelection? langSelect) => AttributeHelper<LanguageSelection?>.GetAttribute(langSelect)?.LongName;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1099,22 +1067,14 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="mediaType"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string LongName(this MediaType? mediaType) => AttributeHelper<MediaType?>.GetAttribute(mediaType)?.LongName;
|
||||
#else
|
||||
public static string? LongName(this MediaType? mediaType) => AttributeHelper<MediaType?>.GetAttribute(mediaType)?.LongName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the Redump shortnames for each known media type
|
||||
/// </summary>
|
||||
/// <param name="mediaType"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string ShortName(this MediaType? mediaType) => AttributeHelper<MediaType?>.GetAttribute(mediaType)?.ShortName;
|
||||
#else
|
||||
public static string? ShortName(this MediaType? mediaType) => AttributeHelper<MediaType?>.GetAttribute(mediaType)?.ShortName;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1125,22 +1085,14 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="region"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string LongName(this Region? region) => AttributeHelper<Region?>.GetAttribute(region)?.LongName;
|
||||
#else
|
||||
public static string? LongName(this Region? region) => AttributeHelper<Region?>.GetAttribute(region)?.LongName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the Redump shortnames for each known region
|
||||
/// </summary>
|
||||
/// <param name="region"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string ShortName(this Region? region) => AttributeHelper<Region?>.GetAttribute(region)?.ShortName;
|
||||
#else
|
||||
public static string? ShortName(this Region? region) => AttributeHelper<Region?>.GetAttribute(region)?.ShortName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the Region enum value for a given string
|
||||
@@ -1172,22 +1124,14 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string LongName(this SiteCode? siteCode) => AttributeHelper<SiteCode?>.GetAttribute(siteCode)?.LongName;
|
||||
#else
|
||||
public static string? LongName(this SiteCode? siteCode) => AttributeHelper<SiteCode?>.GetAttribute(siteCode)?.LongName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the short tag for each known site code
|
||||
/// </summary>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string ShortName(this SiteCode? siteCode) => AttributeHelper<SiteCode?>.GetAttribute(siteCode)?.ShortName;
|
||||
#else
|
||||
public static string? ShortName(this SiteCode? siteCode) => AttributeHelper<SiteCode?>.GetAttribute(siteCode)?.ShortName;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1238,22 +1182,14 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="system"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string LongName(this RedumpSystem? system) => AttributeHelper<RedumpSystem?>.GetAttribute(system)?.LongName;
|
||||
#else
|
||||
public static string? LongName(this RedumpSystem? system) => AttributeHelper<RedumpSystem?>.GetAttribute(system)?.LongName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the Redump shortnames for each known system
|
||||
/// </summary>
|
||||
/// <param name="system"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string ShortName(this RedumpSystem? system) => AttributeHelper<RedumpSystem?>.GetAttribute(system)?.ShortName;
|
||||
#else
|
||||
public static string? ShortName(this RedumpSystem? system) => AttributeHelper<RedumpSystem?>.GetAttribute(system)?.ShortName;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Determine the category of a system
|
||||
@@ -2201,11 +2137,7 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public static string LongName(this SystemCategory? category) => AttributeHelper<SystemCategory?>.GetAttribute(category)?.LongName;
|
||||
#else
|
||||
public static string? LongName(this SystemCategory? category) => AttributeHelper<SystemCategory?>.GetAttribute(category)?.LongName;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -24,11 +24,7 @@ namespace SabreTools.RedumpLib.Data
|
||||
/// List of partially matched Redump IDs
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
#if NET48
|
||||
public List<int> PartiallyMatchedIDs { get; set; }
|
||||
#else
|
||||
public List<int>? PartiallyMatchedIDs { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// DateTime of when the disc was added
|
||||
@@ -43,81 +39,37 @@ namespace SabreTools.RedumpLib.Data
|
||||
public DateTime? LastModified { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "common_disc_info", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public CommonDiscInfoSection CommonDiscInfo { get; set; } = new CommonDiscInfoSection();
|
||||
#else
|
||||
public CommonDiscInfoSection? CommonDiscInfo { get; set; } = new CommonDiscInfoSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "versions_and_editions", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public VersionAndEditionsSection VersionAndEditions { get; set; } = new VersionAndEditionsSection();
|
||||
#else
|
||||
public VersionAndEditionsSection? VersionAndEditions { get; set; } = new VersionAndEditionsSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "edc", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public EDCSection EDC { get; set; } = new EDCSection();
|
||||
#else
|
||||
public EDCSection? EDC { get; set; } = new EDCSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "parent_clone_relationship", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public ParentCloneRelationshipSection ParentCloneRelationship { get; set; } = new ParentCloneRelationshipSection();
|
||||
#else
|
||||
public ParentCloneRelationshipSection? ParentCloneRelationship { get; set; } = new ParentCloneRelationshipSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "extras", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public ExtrasSection Extras { get; set; } = new ExtrasSection();
|
||||
#else
|
||||
public ExtrasSection? Extras { get; set; } = new ExtrasSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "copy_protection", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public CopyProtectionSection CopyProtection { get; set; } = new CopyProtectionSection();
|
||||
#else
|
||||
public CopyProtectionSection? CopyProtection { get; set; } = new CopyProtectionSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "dumpers_and_status", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public DumpersAndStatusSection DumpersAndStatus { get; set; } = new DumpersAndStatusSection();
|
||||
#else
|
||||
public DumpersAndStatusSection? DumpersAndStatus { get; set; } = new DumpersAndStatusSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "tracks_and_write_offsets", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public TracksAndWriteOffsetsSection TracksAndWriteOffsets { get; set; } = new TracksAndWriteOffsetsSection();
|
||||
#else
|
||||
public TracksAndWriteOffsetsSection? TracksAndWriteOffsets { get; set; } = new TracksAndWriteOffsetsSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "size_and_checksums", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public SizeAndChecksumsSection SizeAndChecksums { get; set; } = new SizeAndChecksumsSection();
|
||||
#else
|
||||
public SizeAndChecksumsSection? SizeAndChecksums { get; set; } = new SizeAndChecksumsSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "dumping_info", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public DumpingInfoSection DumpingInfo { get; set; } = new DumpingInfoSection();
|
||||
#else
|
||||
public DumpingInfoSection? DumpingInfo { get; set; } = new DumpingInfoSection();
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "artifacts", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public Dictionary<string, string> Artifacts { get; set; } = new Dictionary<string, string>();
|
||||
#else
|
||||
public Dictionary<string, string>? Artifacts { get; set; } = new Dictionary<string, string>();
|
||||
#endif
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
@@ -159,32 +111,16 @@ namespace SabreTools.RedumpLib.Data
|
||||
public DiscType? Media { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "d_title", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string Title { get; set; }
|
||||
#else
|
||||
public string? Title { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_title_foreign", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string ForeignTitleNonLatin { get; set; }
|
||||
#else
|
||||
public string? ForeignTitleNonLatin { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_number", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string DiscNumberLetter { get; set; }
|
||||
#else
|
||||
public string? DiscNumberLetter { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_label", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string DiscTitle { get; set; }
|
||||
#else
|
||||
public string? DiscTitle { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_category", Required = Required.AllowNull)]
|
||||
[JsonConverter(typeof(DiscCategoryConverter))]
|
||||
@@ -196,228 +132,104 @@ namespace SabreTools.RedumpLib.Data
|
||||
|
||||
[JsonProperty(PropertyName = "d_languages", Required = Required.AllowNull)]
|
||||
[JsonConverter(typeof(LanguageConverter))]
|
||||
#if NET48
|
||||
public Language?[] Languages { get; set; }
|
||||
#else
|
||||
public Language?[]? Languages { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_languages_selection", NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[JsonConverter(typeof(LanguageSelectionConverter))]
|
||||
#if NET48
|
||||
public LanguageSelection?[] LanguageSelection { get; set; }
|
||||
#else
|
||||
public LanguageSelection?[]? LanguageSelection { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_serial", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Serial { get; set; }
|
||||
#else
|
||||
public string? Serial { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Ring { get; private set; }
|
||||
#else
|
||||
public string? Ring { get; private set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_id", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string RingId { get; private set; }
|
||||
#else
|
||||
public string? RingId { get; private set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ma1", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string Layer0MasteringRing { get; set; }
|
||||
#else
|
||||
public string? Layer0MasteringRing { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ma1_sid", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer0MasteringSID { get; set; }
|
||||
#else
|
||||
public string? Layer0MasteringSID { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ts1", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer0ToolstampMasteringCode { get; set; }
|
||||
#else
|
||||
public string? Layer0ToolstampMasteringCode { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_mo1_sid", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer0MouldSID { get; set; }
|
||||
#else
|
||||
public string? Layer0MouldSID { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_mo1", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer0AdditionalMould { get; set; }
|
||||
#else
|
||||
public string? Layer0AdditionalMould { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ma2", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string Layer1MasteringRing { get; set; }
|
||||
#else
|
||||
public string? Layer1MasteringRing { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ma2_sid", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer1MasteringSID { get; set; }
|
||||
#else
|
||||
public string? Layer1MasteringSID { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ts2", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer1ToolstampMasteringCode { get; set; }
|
||||
#else
|
||||
public string? Layer1ToolstampMasteringCode { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_mo2_sid", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer1MouldSID { get; set; }
|
||||
#else
|
||||
public string? Layer1MouldSID { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_mo2", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer1AdditionalMould { get; set; }
|
||||
#else
|
||||
public string? Layer1AdditionalMould { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ma3", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string Layer2MasteringRing { get; set; }
|
||||
#else
|
||||
public string? Layer2MasteringRing { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ma3_sid", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer2MasteringSID { get; set; }
|
||||
#else
|
||||
public string? Layer2MasteringSID { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ts3", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer2ToolstampMasteringCode { get; set; }
|
||||
#else
|
||||
public string? Layer2ToolstampMasteringCode { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ma4", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string Layer3MasteringRing { get; set; }
|
||||
#else
|
||||
public string? Layer3MasteringRing { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ma4_sid", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer3MasteringSID { get; set; }
|
||||
#else
|
||||
public string? Layer3MasteringSID { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_ts4", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Layer3ToolstampMasteringCode { get; set; }
|
||||
#else
|
||||
public string? Layer3ToolstampMasteringCode { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_offsets", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string RingOffsetsHidden { get { return "1"; } }
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_0_id", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string RingZeroId { get; private set; }
|
||||
#else
|
||||
public string? RingZeroId { get; private set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_0_density", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string RingZeroDensity { get; private set; }
|
||||
#else
|
||||
public string? RingZeroDensity { get; private set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_0_0_value", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string RingWriteOffset { get; set; }
|
||||
#else
|
||||
public string? RingWriteOffset { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ring_count", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string RingCount { get { return "1"; } }
|
||||
|
||||
[JsonProperty(PropertyName = "d_barcode", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Barcode { get; set; }
|
||||
#else
|
||||
public string? Barcode { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_date", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string EXEDateBuildDate { get; set; }
|
||||
#else
|
||||
public string? EXEDateBuildDate { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_errors", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string ErrorsCount { get; set; }
|
||||
#else
|
||||
public string? ErrorsCount { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_comments", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Comments { get; set; }
|
||||
#else
|
||||
public string? Comments { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonIgnore]
|
||||
#if NET48
|
||||
public Dictionary<SiteCode?, string> CommentsSpecialFields { get; set; }
|
||||
#else
|
||||
public Dictionary<SiteCode, string>? CommentsSpecialFields { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_contents", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Contents { get; set; }
|
||||
#else
|
||||
public string? Contents { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonIgnore]
|
||||
#if NET48
|
||||
public Dictionary<SiteCode?, string> ContentsSpecialFields { get; set; }
|
||||
#else
|
||||
public Dictionary<SiteCode, string>? ContentsSpecialFields { get; set; }
|
||||
#endif
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
@@ -472,32 +284,16 @@ namespace SabreTools.RedumpLib.Data
|
||||
public class VersionAndEditionsSection : ICloneable
|
||||
{
|
||||
[JsonProperty(PropertyName = "d_version", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Version { get; set; }
|
||||
#else
|
||||
public string? Version { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_version_datfile", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string VersionDatfile { get; set; }
|
||||
#else
|
||||
public string? VersionDatfile { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_editions", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string[] CommonEditions { get; set; }
|
||||
#else
|
||||
public string[]? CommonEditions { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_editions_text", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string OtherEditions { get; set; }
|
||||
#else
|
||||
public string? OtherEditions { get; set; }
|
||||
#endif
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
@@ -535,11 +331,7 @@ namespace SabreTools.RedumpLib.Data
|
||||
public class ParentCloneRelationshipSection : ICloneable
|
||||
{
|
||||
[JsonProperty(PropertyName = "d_parent_id", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string ParentID { get; set; }
|
||||
#else
|
||||
public string? ParentID { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_is_regional_parent", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool RegionalParent { get; set; }
|
||||
@@ -560,53 +352,25 @@ namespace SabreTools.RedumpLib.Data
|
||||
public class ExtrasSection : ICloneable
|
||||
{
|
||||
[JsonProperty(PropertyName = "d_pvd", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string PVD { get; set; }
|
||||
#else
|
||||
public string? PVD { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_d1_key", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string DiscKey { get; set; }
|
||||
#else
|
||||
public string? DiscKey { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_d2_key", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string DiscID { get; set; }
|
||||
#else
|
||||
public string? DiscID { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_pic_data", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string PIC { get; set; }
|
||||
#else
|
||||
public string? PIC { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_header", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Header { get; set; }
|
||||
#else
|
||||
public string? Header { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_bca", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string BCA { get; set; }
|
||||
#else
|
||||
public string? BCA { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_ssranges", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string SecuritySectorRanges { get; set; }
|
||||
#else
|
||||
public string? SecuritySectorRanges { get; set; }
|
||||
#endif
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
@@ -637,32 +401,16 @@ namespace SabreTools.RedumpLib.Data
|
||||
public YesNo? LibCrypt { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "d_libcrypt", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string LibCryptData { get; set; }
|
||||
#else
|
||||
public string? LibCryptData { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_protection", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Protection { get; set; }
|
||||
#else
|
||||
public string? Protection { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonIgnore]
|
||||
#if NET48
|
||||
public Dictionary<string, List<string>> FullProtections { get; set; }
|
||||
#else
|
||||
public Dictionary<string, List<string>?>? FullProtections { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_securom", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string SecuROMData { get; set; }
|
||||
#else
|
||||
public string? SecuROMData { get; set; }
|
||||
#endif
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
@@ -687,18 +435,10 @@ namespace SabreTools.RedumpLib.Data
|
||||
public DumpStatus Status { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "d_dumpers", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string[] Dumpers { get; set; }
|
||||
#else
|
||||
public string[]? Dumpers { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_dumpers_text", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string OtherDumpers { get; set; }
|
||||
#else
|
||||
public string? OtherDumpers { get; set; }
|
||||
#endif
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
@@ -717,32 +457,16 @@ namespace SabreTools.RedumpLib.Data
|
||||
public class TracksAndWriteOffsetsSection : ICloneable
|
||||
{
|
||||
[JsonProperty(PropertyName = "d_tracks", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string ClrMameProData { get; set; }
|
||||
#else
|
||||
public string? ClrMameProData { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_cue", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string Cuesheet { get; set; }
|
||||
#else
|
||||
public string? Cuesheet { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_offset", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public int[] CommonWriteOffsets { get; set; }
|
||||
#else
|
||||
public int[]? CommonWriteOffsets { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_offset_text", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string OtherWriteOffsets { get; set; }
|
||||
#else
|
||||
public string? OtherWriteOffsets { get; set; }
|
||||
#endif
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
@@ -771,35 +495,19 @@ namespace SabreTools.RedumpLib.Data
|
||||
public long Layerbreak3 { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "d_pic_identifier", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string PICIdentifier { get; set; }
|
||||
#else
|
||||
public string? PICIdentifier { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_size", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public long Size { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "d_crc32", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string CRC32 { get; set; }
|
||||
#else
|
||||
public string? CRC32 { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_md5", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string MD5 { get; set; }
|
||||
#else
|
||||
public string? MD5 { get; set; }
|
||||
#endif
|
||||
|
||||
[JsonProperty(PropertyName = "d_sha1", NullValueHandling = NullValueHandling.Ignore)]
|
||||
#if NET48
|
||||
public string SHA1 { get; set; }
|
||||
#else
|
||||
public string? SHA1 { get; set; }
|
||||
#endif
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
@@ -824,51 +532,27 @@ namespace SabreTools.RedumpLib.Data
|
||||
{
|
||||
// Name not defined by Redump
|
||||
[JsonProperty(PropertyName = "d_dumping_program", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string DumpingProgram { get; set; }
|
||||
#else
|
||||
public string? DumpingProgram { get; set; }
|
||||
#endif
|
||||
|
||||
// Name not defined by Redump
|
||||
[JsonProperty(PropertyName = "d_dumping_date", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string DumpingDate { get; set; }
|
||||
#else
|
||||
public string? DumpingDate { get; set; }
|
||||
#endif
|
||||
|
||||
// Name not defined by Redump
|
||||
[JsonProperty(PropertyName = "d_drive_manufacturer", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string Manufacturer { get; set; }
|
||||
#else
|
||||
public string? Manufacturer { get; set; }
|
||||
#endif
|
||||
|
||||
// Name not defined by Redump
|
||||
[JsonProperty(PropertyName = "d_drive_model", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string Model { get; set; }
|
||||
#else
|
||||
public string? Model { get; set; }
|
||||
#endif
|
||||
|
||||
// Name not defined by Redump
|
||||
[JsonProperty(PropertyName = "d_drive_firmware", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string Firmware { get; set; }
|
||||
#else
|
||||
public string? Firmware { get; set; }
|
||||
#endif
|
||||
|
||||
// Name not defined by Redump
|
||||
[JsonProperty(PropertyName = "d_reported_disc_type", Required = Required.AllowNull)]
|
||||
#if NET48
|
||||
public string ReportedDiscType { get; set; }
|
||||
#else
|
||||
public string? ReportedDiscType { get; set; }
|
||||
#endif
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>net48;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>1.1.1</Version>
|
||||
|
||||
<!-- Package Properties -->
|
||||
@@ -18,10 +21,6 @@
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath=""/>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#if NET6_0_OR_GREATER
|
||||
#if !NETFRAMEWORK
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -194,7 +194,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="failOnSingle">True to return on first error, false otherwise</param>
|
||||
/// <returns>True if the page could be downloaded, false otherwise</returns>
|
||||
public async Task<bool> CheckSingleSitePage(string url, string outDir, bool failOnSingle)
|
||||
public async Task<bool> CheckSingleSitePage(string url, string? outDir, bool failOnSingle)
|
||||
{
|
||||
// Try up to 3 times to retrieve the data
|
||||
string? dumpsPage = await DownloadString(url, retries: 3);
|
||||
@@ -282,7 +282,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="failOnSingle">True to return on first error, false otherwise</param>
|
||||
/// <returns>True if the page could be downloaded, false otherwise</returns>
|
||||
public async Task<bool> CheckSingleWIPPage(string url, string outDir, bool failOnSingle)
|
||||
public async Task<bool> CheckSingleWIPPage(string url, string? outDir, bool failOnSingle)
|
||||
{
|
||||
// Try up to 3 times to retrieve the data
|
||||
string? dumpsPage = await DownloadString(url, retries: 3);
|
||||
@@ -344,7 +344,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="system">System to download packs for</param>
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="subfolder">Named subfolder for the pack, used optionally</param>
|
||||
public async Task<bool> DownloadSinglePack(string url, RedumpSystem? system, string outDir, string subfolder)
|
||||
public async Task<bool> DownloadSinglePack(string url, RedumpSystem? system, string? outDir, string? subfolder)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -357,7 +357,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
|
||||
// Make the call to get the pack
|
||||
string? remoteFileName = await DownloadFile(packUri, tempfile);
|
||||
MoveOrDelete(tempfile, remoteFileName, outDir, subfolder);
|
||||
MoveOrDelete(tempfile, remoteFileName, outDir!, subfolder);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -405,7 +405,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="rename">True to rename deleted entries, false otherwise</param>
|
||||
/// <returns>True if all data was downloaded, false otherwise</returns>
|
||||
public async Task<bool> DownloadSingleSiteID(int id, string outDir, bool rename)
|
||||
public async Task<bool> DownloadSingleSiteID(int id, string? outDir, bool rename)
|
||||
{
|
||||
// If no output directory is defined, use the current directory instead
|
||||
if (string.IsNullOrWhiteSpace(outDir))
|
||||
@@ -567,7 +567,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="rename">True to rename deleted entries, false otherwise</param>
|
||||
/// <returns>True if all data was downloaded, false otherwise</returns>
|
||||
public async Task<bool> DownloadSingleWIPID(int id, string outDir, bool rename)
|
||||
public async Task<bool> DownloadSingleWIPID(int id, string? outDir, bool rename)
|
||||
{
|
||||
// If no output directory is defined, use the current directory instead
|
||||
if (string.IsNullOrWhiteSpace(outDir))
|
||||
@@ -694,7 +694,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="title">Name of the pack that is downloading</param>
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="subfolder">Named subfolder for the pack, used optionally</param>
|
||||
public async Task<bool> DownloadPacks(string url, RedumpSystem?[] systems, string title, string outDir, string subfolder)
|
||||
public async Task<bool> DownloadPacks(string url, RedumpSystem?[] systems, string title, string? outDir, string? subfolder)
|
||||
{
|
||||
Console.WriteLine($"Downloading {title}");
|
||||
foreach (var system in systems)
|
||||
@@ -778,7 +778,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="newfile">Path to new output file</param>
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="subfolder">Optional subfolder to append to the path</param>
|
||||
private static void MoveOrDelete(string tempfile, string? newfile, string outDir, string subfolder)
|
||||
private static void MoveOrDelete(string tempfile, string? newfile, string outDir, string? subfolder)
|
||||
{
|
||||
// If we don't have a file to move to, just delete the temp file
|
||||
if (string.IsNullOrWhiteSpace(newfile))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#if NET48
|
||||
#if NETFRAMEWORK
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -29,7 +29,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// Get the last downloaded filename, if possible
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetLastFilename()
|
||||
public string? GetLastFilename()
|
||||
{
|
||||
// If the response headers are null or empty
|
||||
if (ResponseHeaders == null || ResponseHeaders.Count == 0)
|
||||
@@ -41,11 +41,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
return null;
|
||||
|
||||
// Extract the filename from the value
|
||||
#if NETSTANDARD2_1
|
||||
return headerValue[(headerValue.IndexOf("filename=") + 9)..].Replace("\"", "");
|
||||
#else
|
||||
return headerValue.Substring(headerValue.IndexOf("filename=") + 9).Replace("\"", "");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -61,19 +57,15 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <summary>
|
||||
/// Validate supplied credentials
|
||||
/// </summary>
|
||||
public static (bool?, string) ValidateCredentials(string username, string password)
|
||||
public static (bool?, string?) ValidateCredentials(string username, string password)
|
||||
{
|
||||
// If options are invalid or we're missing something key, just return
|
||||
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
|
||||
return (false, null);
|
||||
|
||||
// Try logging in with the supplied credentials otherwise
|
||||
#if NETSTANDARD2_1
|
||||
using RedumpWebClient wc = new RedumpWebClient();
|
||||
#else
|
||||
using (RedumpWebClient wc = new RedumpWebClient())
|
||||
{
|
||||
#endif
|
||||
bool? loggedIn = wc.Login(username, password);
|
||||
if (loggedIn == true)
|
||||
return (true, "Redump username and password accepted!");
|
||||
@@ -81,9 +73,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
return (false, "Redump username and password denied!");
|
||||
else
|
||||
return (null, "An error occurred validating your credentials!");
|
||||
#if NET48
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -216,7 +206,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="failOnSingle">True to return on first error, false otherwise</param>
|
||||
/// <returns>True if the page could be downloaded, false otherwise</returns>
|
||||
public bool CheckSingleSitePage(string url, string outDir, bool failOnSingle)
|
||||
public bool CheckSingleSitePage(string url, string? outDir, bool failOnSingle)
|
||||
{
|
||||
string dumpsPage = string.Empty;
|
||||
|
||||
@@ -323,7 +313,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="failOnSingle">True to return on first error, false otherwise</param>
|
||||
/// <returns>True if the page could be downloaded, false otherwise</returns>
|
||||
public bool CheckSingleWIPPage(string url, string outDir, bool failOnSingle)
|
||||
public bool CheckSingleWIPPage(string url, string? outDir, bool failOnSingle)
|
||||
{
|
||||
string dumpsPage = string.Empty;
|
||||
|
||||
@@ -375,7 +365,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="url">Base URL to download using</param>
|
||||
/// <param name="system">System to download packs for</param>
|
||||
/// <returns>Byte array containing the downloaded pack, null on error</returns>
|
||||
public byte[] DownloadSinglePack(string url, RedumpSystem? system)
|
||||
public byte[]? DownloadSinglePack(string url, RedumpSystem? system)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -395,7 +385,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="system">System to download packs for</param>
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="subfolder">Named subfolder for the pack, used optionally</param>
|
||||
public void DownloadSinglePack(string url, RedumpSystem? system, string outDir, string subfolder)
|
||||
public void DownloadSinglePack(string url, RedumpSystem? system, string? outDir, string? subfolder)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -405,7 +395,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
|
||||
string tempfile = Path.Combine(outDir, "tmp" + Guid.NewGuid().ToString());
|
||||
DownloadFile(string.Format(url, system.ShortName()), tempfile);
|
||||
MoveOrDelete(tempfile, GetLastFilename(), outDir, subfolder);
|
||||
MoveOrDelete(tempfile, GetLastFilename(), outDir!, subfolder);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -418,7 +408,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// </summary>
|
||||
/// <param name="id">Redump disc ID to retrieve</param>
|
||||
/// <returns>String containing the page contents if successful, null on error</returns>
|
||||
public string DownloadSingleSiteID(int id)
|
||||
public string? DownloadSingleSiteID(int id)
|
||||
{
|
||||
string paddedId = id.ToString().PadLeft(6, '0');
|
||||
Console.WriteLine($"Processing ID: {paddedId}");
|
||||
@@ -460,7 +450,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="rename">True to rename deleted entries, false otherwise</param>
|
||||
/// <returns>True if all data was downloaded, false otherwise</returns>
|
||||
public bool DownloadSingleSiteID(int id, string outDir, bool rename)
|
||||
public bool DownloadSingleSiteID(int id, string? outDir, bool rename)
|
||||
{
|
||||
// If no output directory is defined, use the current directory instead
|
||||
if (string.IsNullOrWhiteSpace(outDir))
|
||||
@@ -598,7 +588,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// </summary>
|
||||
/// <param name="id">Redump WIP disc ID to retrieve</param>
|
||||
/// <returns>String containing the page contents if successful, null on error</returns>
|
||||
public string DownloadSingleWIPID(int id)
|
||||
public string? DownloadSingleWIPID(int id)
|
||||
{
|
||||
string paddedId = id.ToString().PadLeft(6, '0');
|
||||
Console.WriteLine($"Processing ID: {paddedId}");
|
||||
@@ -640,7 +630,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="rename">True to rename deleted entries, false otherwise</param>
|
||||
/// <returns>True if all data was downloaded, false otherwise</returns>
|
||||
public bool DownloadSingleWIPID(int id, string outDir, bool rename)
|
||||
public bool DownloadSingleWIPID(int id, string? outDir, bool rename)
|
||||
{
|
||||
// If no output directory is defined, use the current directory instead
|
||||
if (string.IsNullOrWhiteSpace(outDir))
|
||||
@@ -752,12 +742,12 @@ namespace SabreTools.RedumpLib.Web
|
||||
continue;
|
||||
|
||||
// If the system is unknown, we can't do anything
|
||||
string longName = system.LongName();
|
||||
string? longName = system.LongName();
|
||||
if (string.IsNullOrWhiteSpace(longName))
|
||||
continue;
|
||||
|
||||
Console.Write($"\r{longName}{new string(' ', Console.BufferWidth - longName.Length - 1)}");
|
||||
byte[] pack = DownloadSinglePack(url, system);
|
||||
Console.Write($"\r{longName}{new string(' ', Console.BufferWidth - longName!.Length - 1)}");
|
||||
byte[]? pack = DownloadSinglePack(url, system);
|
||||
if (pack != null)
|
||||
packsDictionary.Add(system.Value, pack);
|
||||
}
|
||||
@@ -776,7 +766,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="title">Name of the pack that is downloading</param>
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="subfolder">Named subfolder for the pack, used optionally</param>
|
||||
public void DownloadPacks(string url, RedumpSystem?[] systems, string title, string outDir, string subfolder)
|
||||
public void DownloadPacks(string url, RedumpSystem?[] systems, string title, string? outDir, string? subfolder)
|
||||
{
|
||||
Console.WriteLine($"Downloading {title}");
|
||||
foreach (var system in systems)
|
||||
@@ -790,11 +780,11 @@ namespace SabreTools.RedumpLib.Web
|
||||
continue;
|
||||
|
||||
// If the system is unknown, we can't do anything
|
||||
string longName = system.LongName();
|
||||
string? longName = system.LongName();
|
||||
if (string.IsNullOrWhiteSpace(longName))
|
||||
continue;
|
||||
|
||||
Console.Write($"\r{longName}{new string(' ', Console.BufferWidth - longName.Length - 1)}");
|
||||
Console.Write($"\r{longName}{new string(' ', Console.BufferWidth - longName!.Length - 1)}");
|
||||
DownloadSinglePack(url, system, outDir, subfolder);
|
||||
}
|
||||
|
||||
@@ -809,7 +799,7 @@ namespace SabreTools.RedumpLib.Web
|
||||
/// <param name="newfile">Path to new output file</param>
|
||||
/// <param name="outDir">Output directory to save data to</param>
|
||||
/// <param name="subfolder">Optional subfolder to append to the path</param>
|
||||
private static void MoveOrDelete(string tempfile, string newfile, string outDir, string subfolder)
|
||||
private static void MoveOrDelete(string tempfile, string? newfile, string outDir, string? subfolder)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(newfile))
|
||||
{
|
||||
@@ -827,7 +817,9 @@ namespace SabreTools.RedumpLib.Web
|
||||
File.Move(tempfile, Path.Combine(outDir, newfile));
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Delete(tempfile);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user