Skip to content

Commit 7b590e9

Browse files
committed
Separate out sections to new files for maintainability
1 parent 0968bfe commit 7b590e9

16 files changed

+572
-512
lines changed

SabreTools.RedumpLib.Test/FormatterTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using SabreTools.RedumpLib.Data;
6+
using SabreTools.RedumpLib.Data.Sections;
67
using Xunit;
78

89
namespace SabreTools.RedumpLib.Test
@@ -874,4 +875,4 @@ public void RemoveConsecutiveEmptyLines_Windows_Removed()
874875

875876
#endregion
876877
}
877-
}
878+
}

SabreTools.RedumpLib.Test/SubmissionInfoTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using Newtonsoft.Json;
44
using SabreTools.RedumpLib.Data;
5+
using SabreTools.RedumpLib.Data.Sections;
56
using Xunit;
67

78
namespace SabreTools.RedumpLib.Test

SabreTools.RedumpLib.Test/ValidatorTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using SabreTools.RedumpLib.Data;
2+
using SabreTools.RedumpLib.Data.Sections;
23
using Xunit;
34

45
namespace SabreTools.RedumpLib.Test

SabreTools.RedumpLib/Builder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Xml;
1111
using Newtonsoft.Json;
1212
using SabreTools.RedumpLib.Data;
13+
using SabreTools.RedumpLib.Data.Sections;
1314
using SabreTools.RedumpLib.Web;
1415

1516
namespace SabreTools.RedumpLib
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
using SabreTools.RedumpLib.Converters;
5+
6+
namespace SabreTools.RedumpLib.Data.Sections
7+
{
8+
/// <summary>
9+
/// Common disc info section of New Disc Form
10+
/// </summary>
11+
public class CommonDiscInfoSection : ICloneable
12+
{
13+
// Name not defined by Redump
14+
[JsonProperty(PropertyName = "d_system", DefaultValueHandling = DefaultValueHandling.Include)]
15+
[JsonConverter(typeof(SystemConverter))]
16+
public RedumpSystem? System { get; set; }
17+
18+
// Name not defined by Redump
19+
[JsonProperty(PropertyName = "d_media", DefaultValueHandling = DefaultValueHandling.Include)]
20+
[JsonConverter(typeof(DiscTypeConverter))]
21+
public DiscType? Media { get; set; }
22+
23+
[JsonProperty(PropertyName = "d_title", DefaultValueHandling = DefaultValueHandling.Include)]
24+
public string? Title { get; set; }
25+
26+
[JsonProperty(PropertyName = "d_title_foreign", DefaultValueHandling = DefaultValueHandling.Ignore)]
27+
public string? ForeignTitleNonLatin { get; set; }
28+
29+
[JsonProperty(PropertyName = "d_number", NullValueHandling = NullValueHandling.Ignore)]
30+
public string? DiscNumberLetter { get; set; }
31+
32+
[JsonProperty(PropertyName = "d_label", NullValueHandling = NullValueHandling.Ignore)]
33+
public string? DiscTitle { get; set; }
34+
35+
[JsonProperty(PropertyName = "d_category", DefaultValueHandling = DefaultValueHandling.Include)]
36+
[JsonConverter(typeof(DiscCategoryConverter))]
37+
public DiscCategory? Category { get; set; }
38+
39+
[JsonProperty(PropertyName = "d_region", DefaultValueHandling = DefaultValueHandling.Include)]
40+
[JsonConverter(typeof(RegionConverter))]
41+
public Region? Region { get; set; }
42+
43+
[JsonProperty(PropertyName = "d_languages", DefaultValueHandling = DefaultValueHandling.Include)]
44+
[JsonConverter(typeof(LanguageConverter))]
45+
public Language?[]? Languages { get; set; }
46+
47+
[JsonProperty(PropertyName = "d_languages_selection", NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore)]
48+
[JsonConverter(typeof(LanguageSelectionConverter))]
49+
public LanguageSelection?[]? LanguageSelection { get; set; }
50+
51+
[JsonProperty(PropertyName = "d_serial", NullValueHandling = NullValueHandling.Ignore)]
52+
public string? Serial { get; set; }
53+
54+
[JsonProperty(PropertyName = "d_ring", NullValueHandling = NullValueHandling.Ignore)]
55+
public string? Ring { get; private set; }
56+
57+
[JsonProperty(PropertyName = "d_ring_0_id", NullValueHandling = NullValueHandling.Ignore)]
58+
public string? RingId { get; private set; }
59+
60+
[JsonProperty(PropertyName = "d_ring_0_ma1", DefaultValueHandling = DefaultValueHandling.Include)]
61+
public string? Layer0MasteringRing { get; set; }
62+
63+
[JsonProperty(PropertyName = "d_ring_0_ma1_sid", NullValueHandling = NullValueHandling.Ignore)]
64+
public string? Layer0MasteringSID { get; set; }
65+
66+
[JsonProperty(PropertyName = "d_ring_0_ts1", NullValueHandling = NullValueHandling.Ignore)]
67+
public string? Layer0ToolstampMasteringCode { get; set; }
68+
69+
[JsonProperty(PropertyName = "d_ring_0_mo1_sid", NullValueHandling = NullValueHandling.Ignore)]
70+
public string? Layer0MouldSID { get; set; }
71+
72+
[JsonProperty(PropertyName = "d_ring_0_mo1", NullValueHandling = NullValueHandling.Ignore)]
73+
public string? Layer0AdditionalMould { get; set; }
74+
75+
[JsonProperty(PropertyName = "d_ring_0_ma2", DefaultValueHandling = DefaultValueHandling.Include)]
76+
public string? Layer1MasteringRing { get; set; }
77+
78+
[JsonProperty(PropertyName = "d_ring_0_ma2_sid", NullValueHandling = NullValueHandling.Ignore)]
79+
public string? Layer1MasteringSID { get; set; }
80+
81+
[JsonProperty(PropertyName = "d_ring_0_ts2", NullValueHandling = NullValueHandling.Ignore)]
82+
public string? Layer1ToolstampMasteringCode { get; set; }
83+
84+
[JsonProperty(PropertyName = "d_ring_0_mo2_sid", NullValueHandling = NullValueHandling.Ignore)]
85+
public string? Layer1MouldSID { get; set; }
86+
87+
[JsonProperty(PropertyName = "d_ring_0_mo2", NullValueHandling = NullValueHandling.Ignore)]
88+
public string? Layer1AdditionalMould { get; set; }
89+
90+
[JsonProperty(PropertyName = "d_ring_0_ma3", DefaultValueHandling = DefaultValueHandling.Include)]
91+
public string? Layer2MasteringRing { get; set; }
92+
93+
[JsonProperty(PropertyName = "d_ring_0_ma3_sid", NullValueHandling = NullValueHandling.Ignore)]
94+
public string? Layer2MasteringSID { get; set; }
95+
96+
[JsonProperty(PropertyName = "d_ring_0_ts3", NullValueHandling = NullValueHandling.Ignore)]
97+
public string? Layer2ToolstampMasteringCode { get; set; }
98+
99+
[JsonProperty(PropertyName = "d_ring_0_ma4", DefaultValueHandling = DefaultValueHandling.Include)]
100+
public string? Layer3MasteringRing { get; set; }
101+
102+
[JsonProperty(PropertyName = "d_ring_0_ma4_sid", NullValueHandling = NullValueHandling.Ignore)]
103+
public string? Layer3MasteringSID { get; set; }
104+
105+
[JsonProperty(PropertyName = "d_ring_0_ts4", NullValueHandling = NullValueHandling.Ignore)]
106+
public string? Layer3ToolstampMasteringCode { get; set; }
107+
108+
[JsonProperty(PropertyName = "d_ring_0_offsets", NullValueHandling = NullValueHandling.Ignore)]
109+
public string RingOffsetsHidden { get { return "1"; } }
110+
111+
[JsonProperty(PropertyName = "d_ring_0_0_id", NullValueHandling = NullValueHandling.Ignore)]
112+
public string? RingZeroId { get; private set; }
113+
114+
[JsonProperty(PropertyName = "d_ring_0_0_density", NullValueHandling = NullValueHandling.Ignore)]
115+
public string? RingZeroDensity { get; private set; }
116+
117+
[JsonProperty(PropertyName = "d_ring_0_0_value", NullValueHandling = NullValueHandling.Ignore)]
118+
public string? RingWriteOffset { get; set; }
119+
120+
[JsonProperty(PropertyName = "d_ring_count", NullValueHandling = NullValueHandling.Ignore)]
121+
public string RingCount { get { return "1"; } }
122+
123+
[JsonProperty(PropertyName = "d_barcode", NullValueHandling = NullValueHandling.Ignore)]
124+
public string? Barcode { get; set; }
125+
126+
[JsonProperty(PropertyName = "d_date", NullValueHandling = NullValueHandling.Ignore)]
127+
public string? EXEDateBuildDate { get; set; }
128+
129+
[JsonProperty(PropertyName = "d_errors", NullValueHandling = NullValueHandling.Ignore)]
130+
public string? ErrorsCount { get; set; }
131+
132+
[JsonProperty(PropertyName = "d_comments", NullValueHandling = NullValueHandling.Ignore)]
133+
public string? Comments { get; set; }
134+
135+
[JsonIgnore]
136+
public Dictionary<SiteCode, string> CommentsSpecialFields { get; set; } = [];
137+
138+
[JsonProperty(PropertyName = "d_contents", NullValueHandling = NullValueHandling.Ignore)]
139+
public string? Contents { get; set; }
140+
141+
[JsonIgnore]
142+
public Dictionary<SiteCode, string> ContentsSpecialFields { get; set; } = [];
143+
144+
public object Clone()
145+
{
146+
Dictionary<SiteCode, string> commentsSpecialFields = [];
147+
foreach (var kvp in this.CommentsSpecialFields)
148+
{
149+
commentsSpecialFields[kvp.Key] = kvp.Value;
150+
}
151+
152+
Dictionary<SiteCode, string> contentsSpecialFields = [];
153+
foreach (var kvp in this.ContentsSpecialFields)
154+
{
155+
contentsSpecialFields[kvp.Key] = kvp.Value;
156+
}
157+
158+
return new CommonDiscInfoSection
159+
{
160+
System = this.System,
161+
Media = this.Media,
162+
Title = this.Title,
163+
ForeignTitleNonLatin = this.ForeignTitleNonLatin,
164+
DiscNumberLetter = this.DiscNumberLetter,
165+
DiscTitle = this.DiscTitle,
166+
Category = this.Category,
167+
Region = this.Region,
168+
Languages = this.Languages?.Clone() as Language?[],
169+
LanguageSelection = this.LanguageSelection?.Clone() as LanguageSelection?[],
170+
Serial = this.Serial,
171+
Ring = this.Ring,
172+
RingId = this.RingId,
173+
Layer0MasteringRing = this.Layer0MasteringRing,
174+
Layer0MasteringSID = this.Layer0MasteringSID,
175+
Layer0ToolstampMasteringCode = this.Layer0ToolstampMasteringCode,
176+
Layer0MouldSID = this.Layer0MouldSID,
177+
Layer0AdditionalMould = this.Layer0AdditionalMould,
178+
Layer1MasteringRing = this.Layer1MasteringRing,
179+
Layer1MasteringSID = this.Layer1MasteringSID,
180+
Layer1ToolstampMasteringCode = this.Layer1ToolstampMasteringCode,
181+
Layer1MouldSID = this.Layer1MouldSID,
182+
Layer1AdditionalMould = this.Layer1AdditionalMould,
183+
Layer2MasteringRing = this.Layer2MasteringRing,
184+
Layer2MasteringSID = this.Layer2MasteringSID,
185+
Layer2ToolstampMasteringCode = this.Layer2ToolstampMasteringCode,
186+
Layer3MasteringRing = this.Layer3MasteringRing,
187+
Layer3MasteringSID = this.Layer3MasteringSID,
188+
Layer3ToolstampMasteringCode = this.Layer3ToolstampMasteringCode,
189+
RingZeroId = this.RingZeroId,
190+
RingZeroDensity = this.RingZeroDensity,
191+
RingWriteOffset = this.RingWriteOffset,
192+
Barcode = this.Barcode,
193+
EXEDateBuildDate = this.EXEDateBuildDate,
194+
ErrorsCount = this.ErrorsCount,
195+
Comments = this.Comments,
196+
CommentsSpecialFields = commentsSpecialFields,
197+
Contents = this.Contents,
198+
ContentsSpecialFields = contentsSpecialFields,
199+
};
200+
}
201+
}
202+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
using SabreTools.RedumpLib.Converters;
5+
6+
namespace SabreTools.RedumpLib.Data.Sections
7+
{
8+
/// <summary>
9+
/// Copy protection section of New Disc form
10+
/// </summary>
11+
public class CopyProtectionSection : ICloneable
12+
{
13+
[JsonProperty(PropertyName = "d_protection_a", NullValueHandling = NullValueHandling.Ignore)]
14+
[JsonConverter(typeof(YesNoConverter))]
15+
public YesNo? AntiModchip { get; set; }
16+
17+
[JsonProperty(PropertyName = "d_protection_1", NullValueHandling = NullValueHandling.Ignore)]
18+
[JsonConverter(typeof(YesNoConverter))]
19+
public YesNo? LibCrypt { get; set; }
20+
21+
[JsonProperty(PropertyName = "d_libcrypt", NullValueHandling = NullValueHandling.Ignore)]
22+
public string? LibCryptData { get; set; }
23+
24+
[JsonProperty(PropertyName = "d_protection", NullValueHandling = NullValueHandling.Ignore)]
25+
public string? Protection { get; set; }
26+
27+
[JsonIgnore]
28+
public Dictionary<string, List<string>?>? FullProtections { get; set; }
29+
30+
[JsonProperty(PropertyName = "d_securom", NullValueHandling = NullValueHandling.Ignore)]
31+
public string? SecuROMData { get; set; }
32+
33+
public object Clone()
34+
{
35+
Dictionary<string, List<string>?>? fullProtections = null;
36+
if (this.FullProtections != null)
37+
{
38+
fullProtections = new Dictionary<string, List<string>?>();
39+
foreach (var kvp in this.FullProtections)
40+
{
41+
fullProtections[kvp.Key] = kvp.Value;
42+
}
43+
}
44+
45+
return new CopyProtectionSection
46+
{
47+
AntiModchip = this.AntiModchip,
48+
LibCrypt = this.LibCrypt,
49+
LibCryptData = this.LibCryptData,
50+
Protection = this.Protection,
51+
FullProtections = fullProtections,
52+
SecuROMData = this.SecuROMData,
53+
};
54+
}
55+
}
56+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using Newtonsoft.Json;
3+
4+
namespace SabreTools.RedumpLib.Data.Sections
5+
{
6+
/// <summary>
7+
/// Dumpers and status section of New Disc form (Moderator only)
8+
/// </summary>
9+
public class DumpersAndStatusSection : ICloneable
10+
{
11+
[JsonProperty(PropertyName = "d_status", NullValueHandling = NullValueHandling.Ignore)]
12+
public DumpStatus Status { get; set; }
13+
14+
[JsonProperty(PropertyName = "d_dumpers", NullValueHandling = NullValueHandling.Ignore)]
15+
public string[]? Dumpers { get; set; }
16+
17+
[JsonProperty(PropertyName = "d_dumpers_text", NullValueHandling = NullValueHandling.Ignore)]
18+
public string? OtherDumpers { get; set; }
19+
20+
public object Clone()
21+
{
22+
return new DumpersAndStatusSection
23+
{
24+
Status = this.Status,
25+
Dumpers = this.Dumpers?.Clone() as string[],
26+
OtherDumpers = this.OtherDumpers,
27+
};
28+
}
29+
}
30+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using Newtonsoft.Json;
3+
4+
namespace SabreTools.RedumpLib.Data.Sections
5+
{
6+
/// <summary>
7+
/// Dumping info section for moderation
8+
/// </summary>
9+
public class DumpingInfoSection : ICloneable
10+
{
11+
// Name not defined by Redump -- Only used with MPF
12+
[JsonProperty(PropertyName = "d_frontend_version", DefaultValueHandling = DefaultValueHandling.Include)]
13+
public string? FrontendVersion { get; set; }
14+
15+
// Name not defined by Redump
16+
[JsonProperty(PropertyName = "d_dumping_program", DefaultValueHandling = DefaultValueHandling.Include)]
17+
public string? DumpingProgram { get; set; }
18+
19+
// Name not defined by Redump
20+
[JsonProperty(PropertyName = "d_dumping_date", DefaultValueHandling = DefaultValueHandling.Include)]
21+
public string? DumpingDate { get; set; }
22+
23+
// Name not defined by Redump
24+
[JsonProperty(PropertyName = "d_dumping_params", DefaultValueHandling = DefaultValueHandling.Include)]
25+
public string? DumpingParameters { get; set; }
26+
27+
// Name not defined by Redump
28+
[JsonProperty(PropertyName = "d_drive_manufacturer", DefaultValueHandling = DefaultValueHandling.Include)]
29+
public string? Manufacturer { get; set; }
30+
31+
// Name not defined by Redump
32+
[JsonProperty(PropertyName = "d_drive_model", DefaultValueHandling = DefaultValueHandling.Include)]
33+
public string? Model { get; set; }
34+
35+
// Name not defined by Redump
36+
[JsonProperty(PropertyName = "d_drive_firmware", DefaultValueHandling = DefaultValueHandling.Include)]
37+
public string? Firmware { get; set; }
38+
39+
// Name not defined by Redump
40+
[JsonProperty(PropertyName = "d_reported_disc_type", DefaultValueHandling = DefaultValueHandling.Include)]
41+
public string? ReportedDiscType { get; set; }
42+
43+
// Name not defined by Redump -- Only used with Redumper
44+
[JsonProperty(PropertyName = "d_errors_c2", NullValueHandling = NullValueHandling.Ignore)]
45+
public string? C2ErrorsCount { get; set; }
46+
47+
public object Clone()
48+
{
49+
return new DumpingInfoSection
50+
{
51+
FrontendVersion = this.FrontendVersion,
52+
DumpingProgram = this.DumpingProgram,
53+
DumpingDate = this.DumpingDate,
54+
DumpingParameters = this.DumpingParameters,
55+
Manufacturer = this.Manufacturer,
56+
Model = this.Model,
57+
Firmware = this.Firmware,
58+
ReportedDiscType = this.ReportedDiscType,
59+
C2ErrorsCount = this.C2ErrorsCount,
60+
};
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)