Class AssemblyExtensions
- Namespace
- Cuemon.Extensions.Data.Integrity
- Assembly
- Cuemon.Extensions.Data.Integrity.dll
Extension methods for the Assembly class.
public static class AssemblyExtensions
- Inheritance
-
AssemblyExtensions
Examples
The following example demonstrates generating a
using System;
using System.Reflection;
using Cuemon.Data.Integrity;
using Cuemon.Extensions.Data.Integrity;
namespace MyApp.Examples;
public class AssemblyExtensionsExample
{
public static void Main()
{
// Get a reference to any loaded assembly
Assembly assembly = typeof(AssemblyExtensionsExample).Assembly;
// Generate a CacheValidator from the assembly's file metadata
CacheValidator validator = assembly.GetCacheValidator();
Console.WriteLine($"Assembly: {assembly.GetName().Name}");
Console.WriteLine($"Created (UTC): {validator.Created:O}");
Console.WriteLine($"Modified (UTC): {validator.Modified?.ToString("O") ?? "N/A"}");
Console.WriteLine($"Checksum (hex): {validator.Checksum.ToHexadecimalString()}");
Console.WriteLine($"Validation strength: {validator.Validation}");
// Use the CacheValidator for HTTP cache validation scenarios
Console.WriteLine($"\nETag candidate: \"{validator.Checksum.ToHexadecimalString()}\"");
}
}
Methods
GetCacheValidator(Assembly, Func<Hash>, Action<FileChecksumOptions>)
Returns a CacheValidator from the specified assembly.
public static CacheValidator GetCacheValidator(this Assembly assembly, Func<Hash> hashFactory = null, Action<FileChecksumOptions> setup = null)
Parameters
assemblyAssemblyThe assembly to resolve a CacheValidator from.
hashFactoryFunc<Hash>The function delegate that is invoked to produce the HashResult.
setupAction<FileChecksumOptions>The FileChecksumOptions which may be configured.
Returns
- CacheValidator
A CacheValidator that represents the integrity of the specified
assembly.