Skip to content

Commit e396b3a

Browse files
authored
Override CreateInstance in EncodedHashValue to create the same class instance
Signed-off-by: Xen <lordofxen@deskasoft.com>
1 parent 15ce268 commit e396b3a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

HashifyNet/Core/DataType/EncodedHashValue.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// *
1+
// *
22
// *****************************************************************************
33
// *
44
// * Copyright (c) 2025 Deskasoft International
@@ -62,6 +62,18 @@ public EncodedHashValue(ValueEndianness endianness, IEnumerable<byte> encodedHas
6262
EncodedHash = encodedHash.ToImmutableArray();
6363
}
6464

65+
/// <summary>
66+
/// <inheritdoc/>
67+
/// </summary>
68+
/// <param name="endianness"><inheritdoc/></param>
69+
/// <param name="hash"><inheritdoc/></param>
70+
/// <param name="bitLength"><inheritdoc/></param>
71+
/// <returns><inheritdoc/></returns>
72+
protected override IHashValue CreateInstance(ValueEndianness endianness, ImmutableArray<byte> hash, int bitLength)
73+
{
74+
return new EncodedHashValue(endianness, EncodedHash, _decodeOp, hash, bitLength);
75+
}
76+
6577
/// <summary>
6678
/// <inheritdoc/>
6779
/// </summary>
@@ -82,4 +94,4 @@ public override IHashValue Coerce(int bitLength)
8294
return new EncodedHashValue(Endianness, EncodedHash, _decodeOp, val.AsByteArray(), bitLength);
8395
}
8496
}
85-
}
97+
}

0 commit comments

Comments
 (0)