Files
SabreTools/SabreTools.DatFiles/DepotInformation.cs

67 lines
1.8 KiB
C#
Raw Normal View History

2020-08-20 11:23:48 -07:00
using System;
2024-03-06 11:23:22 -05:00
using SabreTools.Hashing;
2020-08-20 11:23:48 -07:00
namespace SabreTools.DatFiles
2020-08-20 11:23:48 -07:00
{
2020-08-20 13:17:14 -07:00
/// <summary>
/// Depot information wrapper
/// </summary>
2020-08-20 11:23:48 -07:00
public class DepotInformation : ICloneable
{
/// <summary>
/// Name or path of the Depot
/// </summary>
2024-10-19 23:17:37 -04:00
public string? Name { get; }
2020-08-20 11:23:48 -07:00
/// <summary>
/// Whether to use this Depot or not
/// </summary>
2024-10-19 23:17:37 -04:00
public bool IsActive { get; }
2020-08-20 11:23:48 -07:00
/// <summary>
/// Depot byte-depth
/// </summary>
2024-10-19 23:17:37 -04:00
public int Depth { get; }
2020-08-20 11:23:48 -07:00
/// <summary>
/// Constructor
/// </summary>
/// <param name="isActive">Set active state</param>
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
2025-02-13 14:37:05 -05:00
public DepotInformation(bool isActive, int depth)
2024-10-19 23:17:37 -04:00
: this(null, isActive, depth)
2020-08-20 11:23:48 -07:00
{
2024-10-19 23:17:37 -04:00
}
/// <summary>
/// Constructor
/// </summary>
2025-01-29 20:45:07 -05:00
/// <param name="name">Identifier for the depot</param>
2024-10-19 23:17:37 -04:00
/// <param name="isActive">Set active state</param>
/// <param name="depth">Set depth between 0 and SHA-1's byte length</param>
2025-02-13 14:37:05 -05:00
public DepotInformation(string? name, bool isActive, int depth)
2024-10-19 23:17:37 -04:00
{
Name = name;
2020-08-20 11:23:48 -07:00
IsActive = isActive;
Depth = depth;
// Limit depth value
if (Depth == Int32.MinValue)
Depth = 4;
else if (Depth < 0)
Depth = 0;
2025-02-13 14:29:42 -05:00
else if (Depth > ZeroHash.SHA1Arr.Length)
Depth = ZeroHash.SHA1Arr.Length;
2020-08-20 11:23:48 -07:00
}
#region Cloning
/// <summary>
/// Clone the current object
/// </summary>
2024-10-19 23:17:37 -04:00
public object Clone() => new DepotInformation(Name, IsActive, Depth);
2020-08-20 11:23:48 -07:00
#endregion
}
}