diff --git a/SabreTools.Serialization/Models/SGA/DirectoryHeader.cs b/SabreTools.Serialization/Models/SGA/DirectoryHeader.cs index b67284f1..00d8f2bf 100644 --- a/SabreTools.Serialization/Models/SGA/DirectoryHeader.cs +++ b/SabreTools.Serialization/Models/SGA/DirectoryHeader.cs @@ -7,22 +7,22 @@ namespace SabreTools.Data.Models.SGA } /// - public abstract class DirectoryHeader where T : notnull + public abstract class DirectoryHeader where TNumeric : notnull { public uint SectionOffset { get; set; } - public T? SectionCount { get; set; } + public TNumeric? SectionCount { get; set; } public uint FolderOffset { get; set; } - public T? FolderCount { get; set; } + public TNumeric? FolderCount { get; set; } public uint FileOffset { get; set; } - public T? FileCount { get; set; } + public TNumeric? FileCount { get; set; } public uint StringTableOffset { get; set; } - public T? StringTableCount { get; set; } + public TNumeric? StringTableCount { get; set; } } } diff --git a/SabreTools.Serialization/Models/SGA/Folder.cs b/SabreTools.Serialization/Models/SGA/Folder.cs index ab509ce2..fa06f3bb 100644 --- a/SabreTools.Serialization/Models/SGA/Folder.cs +++ b/SabreTools.Serialization/Models/SGA/Folder.cs @@ -9,14 +9,14 @@ namespace SabreTools.Data.Models.SGA } /// - public abstract class Folder : Folder where T : notnull + public abstract class Folder : Folder where TNumeric : notnull { - public T? FolderStartIndex { get; set; } + public TNumeric? FolderStartIndex { get; set; } - public T? FolderEndIndex { get; set; } + public TNumeric? FolderEndIndex { get; set; } - public T? FileStartIndex { get; set; } + public TNumeric? FileStartIndex { get; set; } - public T? FileEndIndex { get; set; } + public TNumeric? FileEndIndex { get; set; } } } diff --git a/SabreTools.Serialization/Models/SGA/Section.cs b/SabreTools.Serialization/Models/SGA/Section.cs index 021f145b..bb8d1dfe 100644 --- a/SabreTools.Serialization/Models/SGA/Section.cs +++ b/SabreTools.Serialization/Models/SGA/Section.cs @@ -9,16 +9,16 @@ namespace SabreTools.Data.Models.SGA } /// - public abstract class Section : Section where T : notnull + public abstract class Section : Section where TNumeric : notnull { - public T? FolderStartIndex { get; set; } + public TNumeric? FolderStartIndex { get; set; } - public T? FolderEndIndex { get; set; } + public TNumeric? FolderEndIndex { get; set; } - public T? FileStartIndex { get; set; } + public TNumeric? FileStartIndex { get; set; } - public T? FileEndIndex { get; set; } + public TNumeric? FileEndIndex { get; set; } - public T? FolderRootIndex { get; set; } + public TNumeric? FolderRootIndex { get; set; } } } diff --git a/SabreTools.Serialization/Wrappers/ObjectExtensions.cs b/SabreTools.Serialization/Wrappers/ObjectExtensions.cs index efea154b..084d611c 100644 --- a/SabreTools.Serialization/Wrappers/ObjectExtensions.cs +++ b/SabreTools.Serialization/Wrappers/ObjectExtensions.cs @@ -10,7 +10,8 @@ namespace SabreTools.Serialization.Wrappers /// internal static class ObjectExtensions { - public static T ThrowOnNull(this T? value) where T : class => value ?? throw new ArgumentNullException(); + public static TClass ThrowOnNull(this TClass? value) where TClass : class + => value ?? throw new ArgumentNullException(); } } diff --git a/SabreTools.Serialization/Wrappers/WrapperBaseT.cs b/SabreTools.Serialization/Wrappers/WrapperBaseT.cs index 0e6c281e..bd864a53 100644 --- a/SabreTools.Serialization/Wrappers/WrapperBaseT.cs +++ b/SabreTools.Serialization/Wrappers/WrapperBaseT.cs @@ -2,17 +2,17 @@ using System.IO; namespace SabreTools.Serialization.Wrappers { - public abstract class WrapperBase : WrapperBase, IWrapper + public abstract class WrapperBase : WrapperBase, IWrapper { #region Properties /// - public T GetModel() => Model; + public TModel GetModel() => Model; /// /// Internal model /// - public T Model { get; } + public TModel Model { get; } #endregion @@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Model to be used in the wrapper /// Underlying data for the wrapper - protected WrapperBase(T model, byte[] data) + protected WrapperBase(TModel model, byte[] data) : this(model, data, 0, data.Length) { } @@ -34,7 +34,7 @@ namespace SabreTools.Serialization.Wrappers /// Model to be used in the wrapper /// Underlying data for the wrapper /// Offset into the data to use as the window start - protected WrapperBase(T model, byte[] data, int offset) + protected WrapperBase(TModel model, byte[] data, int offset) : this(model, data, offset, data.Length - offset) { } @@ -46,7 +46,7 @@ namespace SabreTools.Serialization.Wrappers /// Underlying data for the wrapper /// Offset into the data to use as the window start /// Length of the window into the data - protected WrapperBase(T model, byte[] data, int offset, int length) + protected WrapperBase(TModel model, byte[] data, int offset, int length) : base(data, offset, length) { Model = model; @@ -62,7 +62,7 @@ namespace SabreTools.Serialization.Wrappers /// Model to be used in the wrapper /// Underlying data for the wrapper /// Uses the current stream position as the offset - protected WrapperBase(T model, Stream data) + protected WrapperBase(TModel model, Stream data) : this(model, data, data.Position, data.Length - data.Position) { } @@ -73,7 +73,7 @@ namespace SabreTools.Serialization.Wrappers /// Model to be used in the wrapper /// Underlying data for the wrapper /// Offset into the data to use as the window start - protected WrapperBase(T model, Stream data, long offset) + protected WrapperBase(TModel model, Stream data, long offset) : this(model, data, offset, data.Length - offset) { } @@ -85,7 +85,7 @@ namespace SabreTools.Serialization.Wrappers /// Underlying data for the wrapper /// Offset into the data to use as the window start /// Length of the window into the data - protected WrapperBase(T model, Stream data, long offset, long length) + protected WrapperBase(TModel model, Stream data, long offset, long length) : base(data, offset, length) { Model = model;