using System.IO; namespace SabreTools.Wrappers { public abstract class WrapperBase : WrapperBase, IWrapper { #region Properties /// public TModel GetModel() => Model; /// /// Internal model /// public TModel Model { get; } #endregion #region Byte Array Constructors /// /// Construct a new instance of the wrapper from a byte array /// /// Model to be used in the wrapper /// Underlying data for the wrapper protected WrapperBase(TModel model, byte[] data) : this(model, data, 0, data.Length) { } /// /// Construct a new instance of the wrapper from a byte array /// /// Model to be used in the wrapper /// Underlying data for the wrapper /// Offset into the data to use as the window start protected WrapperBase(TModel model, byte[] data, int offset) : this(model, data, offset, data.Length - offset) { } /// /// Construct a new instance of the wrapper from a byte array /// /// Model to be used in the wrapper /// Underlying data for the wrapper /// Offset into the data to use as the window start /// Length of the window into the data protected WrapperBase(TModel model, byte[] data, int offset, int length) : base(data, offset, length) { Model = model; } #endregion #region Stream Constructors /// /// Construct a new instance of the wrapper from a Stream /// /// Model to be used in the wrapper /// Underlying data for the wrapper /// Uses the current stream position as the offset protected WrapperBase(TModel model, Stream data) : this(model, data, data.Position, data.Length - data.Position) { } /// /// Construct a new instance of the wrapper from a Stream /// /// Model to be used in the wrapper /// Underlying data for the wrapper /// Offset into the data to use as the window start protected WrapperBase(TModel model, Stream data, long offset) : this(model, data, offset, data.Length - offset) { } /// /// Construct a new instance of the wrapper from a Stream /// /// Model to be used in the wrapper /// Underlying data for the wrapper /// Offset into the data to use as the window start /// Length of the window into the data protected WrapperBase(TModel model, Stream data, long offset, long length) : base(data, offset, length) { Model = model; } #endregion } }