Table of Contents

Class CacheValidatorExtensions

Namespace
Cuemon.Extensions.AspNetCore.Data.Integrity
Assembly
Cuemon.Extensions.AspNetCore.dll

Extension methods for the CacheValidator class.

public static class CacheValidatorExtensions
Inheritance
CacheValidatorExtensions

Examples

The following example demonstrates how to turn assembly-backed cache validators into ETag headers for weak and strong validation scenarios.

using System;
using Cuemon.Data.Integrity;
using Cuemon.Extensions.AspNetCore.Data.Integrity;
using Microsoft.Net.Http.Headers;

namespace DocfxExamples;

public class CacheValidatorExtensionsExample
{
    public static void Demonstrate()
    {
        CacheValidator weakValidator = CacheValidatorFactory.CreateValidator(typeof(CacheValidatorExtensionsExample).Assembly);
        EntityTagHeaderValue weakEntityTag = weakValidator.ToEntityTagHeaderValue();

        CacheValidator strongValidator = CacheValidatorFactory.CreateValidator(
            typeof(CacheValidatorExtensionsExample).Assembly,
            setup: options => options.BytesToRead = int.MaxValue);

        EntityTagHeaderValue strongEntityTag = strongValidator.ToEntityTagHeaderValue();

        Console.WriteLine(weakEntityTag);
        Console.WriteLine(strongEntityTag);
    }
}

Methods

ToEntityTagHeaderValue(CacheValidator)

Creates an EntityTagHeaderValue from the specified validator.

public static EntityTagHeaderValue ToEntityTagHeaderValue(this CacheValidator validator)

Parameters

validator CacheValidator

The validator to extend.

Returns

EntityTagHeaderValue

An EntityTagHeaderValue that is initiated with a hexadecimal representation of Checksum and a value that indicates if the tag is weak.