Files
UVtools/UVtools.Core/Objects/NullTerminatedUintStringBigEndian.cs
T
Tiago Conceição 702b73d5e2 v2.27.5
- **Pixel Arithmetic:**
  - (Add) Corode: Noise pixel area, defaulting to 3px2
  - (Change) Corode: Cryptonumeric random to normal random to speed up calculation
  - (Change) Fuzzy skin preset: Set a ignore threshold area of 5000px2
  - (Improvement) Masking performance and auto crop the layer to speed up the processing when using an "Apply to" other than "All"
  - (Fix) Some "Apply to" methods was creating a wrong mask with some operators
- **CXDLP V3:**
   - (Fix) Checksum (CRC32) (#389)
   - (Fix) Software name and material name serialization
2022-01-05 01:10:46 +00:00

62 lines
1.8 KiB
C#

/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using BinarySerialization;
namespace UVtools.Core.Objects
{
/// <summary>
/// A string that always end with 0x00 if not null
/// It contains the string length as uint
/// </summary>
public sealed class NullTerminatedUintStringBigEndian
{
[FieldOrder(0)] [FieldEndianness(Endianness.Big)]
public uint SerializedLength { get; set; }
[FieldOrder(1)] [FieldLength(nameof(SerializedLength))]
public string SerializedValue { get; set; }
[Ignore]
public string Value
{
get => SerializedValue?.TrimEnd(char.MinValue);
set => SerializedValue = value is null ? null : $"{value}{char.MinValue}";
}
public NullTerminatedUintStringBigEndian() { }
public NullTerminatedUintStringBigEndian(string value)
{
Value = value;
}
public override string ToString() => Value;
private bool Equals(NullTerminatedUintStringBigEndian other)
{
return SerializedValue == other.SerializedValue;
}
public bool Equals(string value)
{
return Value == value;
}
public override bool Equals(object obj)
{
return ReferenceEquals(this, obj) || obj is NullTerminatedUintStringBigEndian other && Equals(other);
}
public override int GetHashCode()
{
return (SerializedValue != null ? SerializedValue.GetHashCode() : 0);
}
}
}