diff --git a/CHANGELIST.md b/CHANGELIST.md
index fc9f7090..22f037c9 100644
--- a/CHANGELIST.md
+++ b/CHANGELIST.md
@@ -54,6 +54,7 @@
- Add support for all ISO language codes
- Add support for all ISO region codes
- Ensure ordering in output site tags
+- Make site code formatting helper method
### 2.2 (2021-12-30)
- Fix Saturn header finding
diff --git a/MPF.Library/InfoTool.cs b/MPF.Library/InfoTool.cs
index 90b75b1c..bd092b8f 100644
--- a/MPF.Library/InfoTool.cs
+++ b/MPF.Library/InfoTool.cs
@@ -892,22 +892,7 @@ namespace MPF.Library
"\n", info.CommonDiscInfo.CommentsSpecialFields
.OrderBy(kvp => kvp.Key)
.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Value))
- .Select(kvp =>
- {
- bool isMultiLine = IsMultiLine(kvp.Key);
- string line = $"{kvp.Key.ShortName()}{(isMultiLine ? "\n" : " ")}";
-
- // Special case for boolean fields
- if (kvp.Key == SiteCode.PostgapType || kvp.Key == SiteCode.VCD)
- {
- if (kvp.Value != true.ToString())
- return string.Empty;
-
- return line.Trim();
- }
-
- return $"{line}{kvp.Value}{(isMultiLine ? "\n" : string.Empty)}";
- })
+ .Select(FormatSiteTag)
.Where(s => !string.IsNullOrEmpty(s))
) + "\n" + info.CommonDiscInfo.Comments;
@@ -930,22 +915,7 @@ namespace MPF.Library
"\n", info.CommonDiscInfo.ContentsSpecialFields
.OrderBy(kvp => kvp.Key)
.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Value))
- .Select(kvp =>
- {
- bool isMultiLine = IsMultiLine(kvp.Key);
- string line = $"{kvp.Key.ShortName()}{(isMultiLine ? "\n" : " ")}";
-
- // Special case for boolean fields
- if (kvp.Key == SiteCode.PostgapType || kvp.Key == SiteCode.VCD)
- {
- if (kvp.Value != true.ToString())
- return string.Empty;
-
- return line.Trim();
- }
-
- return $"{line}{kvp.Value}{(isMultiLine ? "\n" : string.Empty)}";
- })
+ .Select(FormatSiteTag)
.Where(s => !string.IsNullOrEmpty(s))
) + "\n" + info.CommonDiscInfo.Contents;
@@ -1090,6 +1060,28 @@ namespace MPF.Library
AddIfExists(output, key, string.Join(", ", value.Select(o => o.ToString())), indent);
}
+ ///
+ /// Format a single site tag to string
+ ///
+ /// KeyValuePair representing the site tag and value
+ /// String-formatted tag and value
+ private static string FormatSiteTag(KeyValuePair kvp)
+ {
+ bool isMultiLine = IsMultiLine(kvp.Key);
+ string line = $"{kvp.Key.ShortName()}{(isMultiLine ? "\n" : " ")}";
+
+ // Special case for boolean fields
+ if (kvp.Key == SiteCode.PostgapType || kvp.Key == SiteCode.VCD)
+ {
+ if (kvp.Value != true.ToString())
+ return string.Empty;
+
+ return line.Trim();
+ }
+
+ return $"{line}{kvp.Value}{(isMultiLine ? "\n" : string.Empty)}";
+ }
+
#endregion
#region Normalization