Table of Contents

AssemblyExtensions Class

Definition

Namespace
Cuemon.Extensions.Data.Integrity
Assemblies
Cuemon.Extensions.Data.Integrity.dll
Source
src/Cuemon.Extensions.Data.Integrity/AssemblyExtensions.cs

Extension methods for the Assembly class.

public static class AssemblyExtensions
Inheritance
AssemblyExtensions

Examples

The following example demonstrates generating a from an assembly using the GetCacheValidator extension method.

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

Name Description
GetCacheValidator(Assembly, Func<Hash>, Action<FileChecksumOptions>)

Returns a CacheValidator from the specified assembly.