Class ChecksumBuilderExtensions
- Namespace
- Cuemon.Extensions.Data.Integrity
- Assembly
- Cuemon.Extensions.Data.Integrity.dll
Extension methods for the ChecksumBuilder class.
public static class ChecksumBuilderExtensions
- Inheritance
-
ChecksumBuilderExtensions
Examples
The following example demonstrates how to use ChecksumBuilderExtensions to fluently combine typed values directly on a ChecksumBuilder instance.
using System;
using Cuemon.Data.Integrity;
using Cuemon.Extensions.Data.Integrity;
using Cuemon.Security;
namespace MyApp.Examples;
public class Example
{
public void Run()
{
// Create a ChecksumBuilder and use extension methods directly
var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());
// Extension methods allow combining typed values without a Decorator wrapper
builder.CombineWith(42); // int overload
builder.CombineWith(3.14); // double overload
builder.CombineWith("data"); // string overload
Console.WriteLine($"Combined checksum: {builder}");
// Works with all numeric types
var checksum = new ChecksumBuilder(() => HashFactory.CreateFnv32())
.CombineWith((short)1)
.CombineWith(2u)
.CombineWith(3L)
.CombineWith(4.0f)
.CombineWith(5ul);
Console.WriteLine($"All types: {checksum}");
// Combine with byte arrays
var withBytes = new ChecksumBuilder(() => HashFactory.CreateFnv32())
.CombineWith(new byte[] { 0x01, 0x02, 0x03 });
Console.WriteLine($"With bytes: {withBytes}");
}
}
Methods
CombineWith<T>(T, byte[])
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, byte[] additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumbyte[]An array of bytes containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.
CombineWith<T>(T, double)
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, double additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumdoubleA double value containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.
CombineWith<T>(T, short)
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, short additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumshortAn short value containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.
CombineWith<T>(T, int)
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, int additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumintAn int value containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.
CombineWith<T>(T, long)
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, long additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumlongAn long value containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.
CombineWith<T>(T, float)
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, float additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumfloatA float value containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.
CombineWith<T>(T, string)
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, string additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumstringA string value containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.
CombineWith<T>(T, ushort)
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, ushort additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumushortAn ushort value containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.
CombineWith<T>(T, uint)
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, uint additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumuintAn uint value containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.
CombineWith<T>(T, ulong)
Combines the additionalChecksum to the representation of this instance.
public static T CombineWith<T>(this T cb, ulong additionalChecksum) where T : ChecksumBuilder
Parameters
cbTThe ChecksumBuilder to extend.
additionalChecksumulongAn ulong value containing a checksum of the additional data this instance must represent.
Returns
- T
An updated instance of the specified
cbofT.
Type Parameters
TThe type of the ChecksumBuilder.