Skip to content

Commit 924aa26

Browse files
feature/v2
- Converted fields to properties for value semantic objects.
1 parent 29cf49f commit 924aa26

27 files changed

+583
-459
lines changed

OnixLabs.Core/Text/Base16.Equatable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace OnixLabs.Core.Text
5151
/// <returns>true if the object is equal to this instance; otherwise, false.</returns>
5252
public bool Equals(Base16 other)
5353
{
54-
return other.value.SequenceEqual(value);
54+
return other.Value.SequenceEqual(Value);
5555
}
5656

5757
/// <summary>
@@ -70,7 +70,7 @@ public override bool Equals(object? obj)
7070
/// <returns>A hash code for this instance.</returns>
7171
public override int GetHashCode()
7272
{
73-
return HashCode.Combine(value);
73+
return HashCode.Combine(Value);
7474
}
7575
}
7676
}

OnixLabs.Core/Text/Base16.To.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public readonly partial struct Base16
2828
/// <returns>Returns a <see cref="byte"/> array that represents the current object.</returns>
2929
public byte[] ToByteArray()
3030
{
31-
return value.Copy();
31+
return Value.Copy();
3232
}
3333

3434
/// <summary>
@@ -47,7 +47,7 @@ public string ToPlainTextString()
4747
/// <returns>Returns a <see cref="string"/> that represents the current object in plain text.</returns>
4848
public string ToPlainTextString(Encoding encoding)
4949
{
50-
return encoding.GetString(value);
50+
return encoding.GetString(Value);
5151
}
5252

5353
/// <summary>
@@ -56,7 +56,7 @@ public string ToPlainTextString(Encoding encoding)
5656
/// <returns>A <see cref="string"/> that represents the current object.</returns>
5757
public override string ToString()
5858
{
59-
return Convert.ToHexString(value).ToLower();
59+
return Convert.ToHexString(Value).ToLower();
6060
}
6161
}
6262
}

OnixLabs.Core/Text/Base16.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ namespace OnixLabs.Core.Text
1919
/// </summary>
2020
public readonly partial struct Base16
2121
{
22-
/// <summary>
23-
/// The underlying value.
24-
/// </summary>
25-
private readonly byte[] value;
26-
2722
/// <summary>
2823
/// Initializes a new instance of the <see cref="Base16"/> struct.
2924
/// </summary>
3025
/// <param name="value">The underlying value.</param>
3126
private Base16(byte[] value)
3227
{
33-
this.value = value;
28+
Value = value;
3429
}
30+
31+
/// <summary>
32+
/// Gets the underlying value.
33+
/// </summary>
34+
private byte[] Value { get; }
3535
}
3636
}

OnixLabs.Core/Text/Base32.Equatable.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ namespace OnixLabs.Core.Text
5151
/// <returns>true if the object is equal to this instance; otherwise, false.</returns>
5252
public bool Equals(Base32 other)
5353
{
54-
return other.value.SequenceEqual(value)
55-
&& other.alphabet == alphabet
56-
&& other.padding == padding;
54+
return other.Value.SequenceEqual(Value)
55+
&& other.Alphabet == Alphabet
56+
&& other.Padding == Padding;
5757
}
5858

5959
/// <summary>
@@ -72,7 +72,7 @@ public override bool Equals(object? obj)
7272
/// <returns>A hash code for this instance.</returns>
7373
public override int GetHashCode()
7474
{
75-
return HashCode.Combine(value);
75+
return HashCode.Combine(Value);
7676
}
7777
}
7878
}

OnixLabs.Core/Text/Base32.To.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public readonly partial struct Base32
2727
/// <returns>Returns a <see cref="byte"/> array that represents the current object.</returns>
2828
public byte[] ToByteArray()
2929
{
30-
return value.Copy();
30+
return Value.Copy();
3131
}
3232

3333
/// <summary>
@@ -46,7 +46,7 @@ public string ToPlainTextString()
4646
/// <returns>Returns a <see cref="string"/> that represents the current object in plain text.</returns>
4747
public string ToPlainTextString(Encoding encoding)
4848
{
49-
return encoding.GetString(value);
49+
return encoding.GetString(Value);
5050
}
5151

5252
/// <summary>
@@ -55,7 +55,7 @@ public string ToPlainTextString(Encoding encoding)
5555
/// <returns>A <see cref="string"/> that represents the current object.</returns>
5656
public override string ToString()
5757
{
58-
return Encode(value, alphabet.Alphabet, padding);
58+
return Encode(Value, Alphabet.Alphabet, Padding);
5959
}
6060
}
6161
}

OnixLabs.Core/Text/Base32.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,31 @@ namespace OnixLabs.Core.Text
2020
public readonly partial struct Base32
2121
{
2222
/// <summary>
23-
/// The underlying value.
23+
/// Initializes a new instance of the <see cref="Base32"/> struct.
2424
/// </summary>
25-
private readonly byte[] value;
25+
/// <param name="value">The underlying value.</param>
26+
/// <param name="alphabet">The alphabet that will be used for Base-32 encoding and decoding operations.</param>
27+
/// <param name="padding">Determines whether padding should be applied for Base-32 encoding and decoding operations.</param>
28+
private Base32(byte[] value, Base32Alphabet alphabet, bool padding)
29+
{
30+
Value = value;
31+
Alphabet = alphabet;
32+
Padding = padding;
33+
}
2634

2735
/// <summary>
28-
/// The alphabet that will be used for Base-32 encoding and decoding operations.
36+
/// Gets the underlying value.
2937
/// </summary>
30-
private readonly Base32Alphabet alphabet;
38+
private byte[] Value { get; }
3139

3240
/// <summary>
33-
/// Determines whether padding should be applied for Base-32 encoding and decoding operations.
41+
/// Gets the alphabet that will be used for Base-32 encoding and decoding operations.
3442
/// </summary>
35-
private readonly bool padding;
43+
private Base32Alphabet Alphabet { get; }
3644

3745
/// <summary>
38-
/// Initializes a new instance of the <see cref="Base32"/> struct.
46+
/// Gets a value that determines whether padding should be applied for Base-32 encoding and decoding operations.
3947
/// </summary>
40-
/// <param name="value">The underlying value.</param>
41-
/// <param name="alphabet">The alphabet that will be used for Base-32 encoding and decoding operations.</param>
42-
/// <param name="padding">Determines whether padding should be applied for Base-32 encoding and decoding operations.</param>
43-
private Base32(byte[] value, Base32Alphabet alphabet, bool padding)
44-
{
45-
this.value = value;
46-
this.alphabet = alphabet;
47-
this.padding = padding;
48-
}
48+
private bool Padding { get; }
4949
}
5050
}

OnixLabs.Core/Text/Base58.Equatable.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ namespace OnixLabs.Core.Text
5151
/// <returns>true if the object is equal to this instance; otherwise, false.</returns>
5252
public bool Equals(Base58 other)
5353
{
54-
return other.value.SequenceEqual(value)
55-
&& other.alphabet == alphabet;
54+
return other.Value.SequenceEqual(Value)
55+
&& other.Alphabet == Alphabet;
5656
}
5757

5858
/// <summary>
@@ -71,7 +71,7 @@ public override bool Equals(object? obj)
7171
/// <returns>A hash code for this instance.</returns>
7272
public override int GetHashCode()
7373
{
74-
return HashCode.Combine(value);
74+
return HashCode.Combine(Value);
7575
}
7676
}
7777
}

OnixLabs.Core/Text/Base58.To.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public readonly partial struct Base58
2727
/// <returns>Returns a <see cref="byte"/> array that represents the current object.</returns>
2828
public byte[] ToByteArray()
2929
{
30-
return value.Copy();
30+
return Value.Copy();
3131
}
3232

3333
/// <summary>
@@ -36,8 +36,8 @@ public byte[] ToByteArray()
3636
/// <returns>A <see cref="string"/> that represents the current object, with a checksum.</returns>
3737
public string ToStringWithChecksum()
3838
{
39-
byte[] valueWithChecksum = AddChecksum(value);
40-
return Encode(valueWithChecksum, alphabet.Alphabet);
39+
byte[] valueWithChecksum = AddChecksum(Value);
40+
return Encode(valueWithChecksum, Alphabet.Alphabet);
4141
}
4242

4343
/// <summary>
@@ -56,7 +56,7 @@ public string ToPlainTextString()
5656
/// <returns>Returns a <see cref="string"/> that represents the current object in plain text.</returns>
5757
public string ToPlainTextString(Encoding encoding)
5858
{
59-
return encoding.GetString(value);
59+
return encoding.GetString(Value);
6060
}
6161

6262

@@ -66,7 +66,7 @@ public string ToPlainTextString(Encoding encoding)
6666
/// <returns>A <see cref="string"/> that represents the current object.</returns>
6767
public override string ToString()
6868
{
69-
return Encode(value, alphabet.Alphabet);
69+
return Encode(Value, Alphabet.Alphabet);
7070
}
7171
}
7272
}

OnixLabs.Core/Text/Base58.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ namespace OnixLabs.Core.Text
1919
/// </summary>
2020
public readonly partial struct Base58
2121
{
22-
/// <summary>
23-
/// The underlying value.
24-
/// </summary>
25-
private readonly byte[] value;
26-
27-
/// <summary>
28-
/// The alphabet that will be used for Base-58 encoding and decoding operations.
29-
/// </summary>
30-
private readonly Base58Alphabet alphabet;
31-
3222
/// <summary>
3323
/// Initializes a new instance of the <see cref="Base58"/> struct.
3424
/// </summary>
3525
/// <param name="value">The underlying value.</param>
3626
/// <param name="alphabet">The alphabet that will be used for Base-58 encoding and decoding operations.</param>
3727
private Base58(byte[] value, Base58Alphabet alphabet)
3828
{
39-
this.value = value;
40-
this.alphabet = alphabet;
29+
Value = value;
30+
Alphabet = alphabet;
4131
}
32+
33+
/// <summary>
34+
/// Gets the underlying value.
35+
/// </summary>
36+
private byte[] Value { get; }
37+
38+
/// <summary>
39+
/// Gets the alphabet that will be used for Base-58 encoding and decoding operations.
40+
/// </summary>
41+
private Base58Alphabet Alphabet { get; }
4242
}
4343
}

OnixLabs.Core/Text/Base64.Equatable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace OnixLabs.Core.Text
5151
/// <returns>true if the object is equal to this instance; otherwise, false.</returns>
5252
public bool Equals(Base64 other)
5353
{
54-
return other.value.SequenceEqual(value);
54+
return other.Value.SequenceEqual(Value);
5555
}
5656

5757
/// <summary>
@@ -70,7 +70,7 @@ public override bool Equals(object? obj)
7070
/// <returns>A hash code for this instance.</returns>
7171
public override int GetHashCode()
7272
{
73-
return HashCode.Combine(value);
73+
return HashCode.Combine(Value);
7474
}
7575
}
7676
}

0 commit comments

Comments
 (0)