diff --git a/SabreTools.Serialization/Deserializers/InstallShieldCabinet.cs b/SabreTools.Serialization/Deserializers/InstallShieldCabinet.cs
index 95d1e17b..9dcfaaf9 100644
--- a/SabreTools.Serialization/Deserializers/InstallShieldCabinet.cs
+++ b/SabreTools.Serialization/Deserializers/InstallShieldCabinet.cs
@@ -36,7 +36,7 @@ namespace SabreTools.Serialization.Deserializers
#endregion
// Get the major version
- int majorVersion = GetMajorVersion(commonHeader);
+ int majorVersion = commonHeader.GetMajorVersion();
#region Volume Header
@@ -725,30 +725,5 @@ namespace SabreTools.Serialization.Deserializers
return obj;
}
-
- #region Helpers
-
- ///
- /// Get the major version of the cabinet
- ///
- /// This should live in the wrapper but is needed during parsing
- public static int GetMajorVersion(CommonHeader commonHeader)
- {
- uint majorVersion = commonHeader.Version;
- if (majorVersion >> 24 == 1)
- {
- majorVersion = (majorVersion >> 12) & 0x0F;
- }
- else if (majorVersion >> 24 == 2 || majorVersion >> 24 == 4)
- {
- majorVersion = majorVersion & 0xFFFF;
- if (majorVersion != 0)
- majorVersion /= 100;
- }
-
- return (int)majorVersion;
- }
-
- #endregion
}
}
diff --git a/SabreTools.Serialization/Extensions.InstallShieldCabinet.cs b/SabreTools.Serialization/Extensions.InstallShieldCabinet.cs
new file mode 100644
index 00000000..08d0e091
--- /dev/null
+++ b/SabreTools.Serialization/Extensions.InstallShieldCabinet.cs
@@ -0,0 +1,47 @@
+using SabreTools.Models.InstallShieldCabinet;
+
+namespace SabreTools.Serialization
+{
+ public static partial class Extensions
+ {
+ ///
+ /// Get the major version of an InstallShield Cabinet
+ ///
+ /// Cabinet to derive the version from
+ /// Major version of the cabinet, -1 on error
+ public static int GetMajorVersion(this Cabinet? cabinet)
+ {
+ // Ignore invalid cabinets
+ if (cabinet == null)
+ return -1;
+
+ return cabinet.CommonHeader.GetMajorVersion();
+ }
+
+ ///
+ /// Get the major version of an InstallShield Cabinet
+ ///
+ /// CommonHeader to derive the version from
+ /// Major version of the cabinet, -1 on error
+ public static int GetMajorVersion(this CommonHeader? commonHeader)
+ {
+ // Ignore invalid headers
+ if (commonHeader == null)
+ return -1;
+
+ uint majorVersion = commonHeader.Version;
+ if (majorVersion >> 24 == 1)
+ {
+ majorVersion = (majorVersion >> 12) & 0x0F;
+ }
+ else if (majorVersion >> 24 == 2 || majorVersion >> 24 == 4)
+ {
+ majorVersion &= 0xFFFF;
+ if (majorVersion != 0)
+ majorVersion /= 100;
+ }
+
+ return (int)majorVersion;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs
index 1a19f6ad..4bfa9586 100644
--- a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs
+++ b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs
@@ -64,25 +64,7 @@ namespace SabreTools.Serialization.Wrappers
///
/// The major version of the cabinet
///
- public int MajorVersion
- {
- get
- {
- uint majorVersion = Model.CommonHeader?.Version ?? 0;
- if (majorVersion >> 24 == 1)
- {
- majorVersion = (majorVersion >> 12) & 0x0F;
- }
- else if (majorVersion >> 24 == 2 || majorVersion >> 24 == 4)
- {
- majorVersion = majorVersion & 0xFFFF;
- if (majorVersion != 0)
- majorVersion /= 100;
- }
-
- return (int)majorVersion;
- }
- }
+ public int MajorVersion => Model.CommonHeader.GetMajorVersion();
#endregion