Faactory.Types 2.0.1

dotnet add package Faactory.Types --version 2.0.1
                    
NuGet\Install-Package Faactory.Types -Version 2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Faactory.Types" Version="2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Faactory.Types" Version="2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Faactory.Types" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Faactory.Types --version 2.0.1
                    
#r "nuget: Faactory.Types, 2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Faactory.Types@2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Faactory.Types&version=2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Faactory.Types&version=2.0.1
                    
Install as a Cake Tool

.NET Foundation

Small, reusable .NET building blocks.

  • Faactory.Types provides small runtime types and encoding utilities.
  • Faactory.Caching provides a typed object cache over IDistributedCache, including negative entries.
  • Faactory.Http provides named HTTP clients with object caching and optional request authorization.

Install only the packages you need:

dotnet add package Faactory.Types
dotnet add package Faactory.Caching
dotnet add package Faactory.Http

Runtime types

Unique identifiers

UniqueId generates compact, URL-safe identifiers using cryptographically secure randomness.

string id = UniqueId.New();
// id_fxOniKPDBAktptggIajv5DyIjBUOVx92

string orderedId = UniqueId.NewTimeOrdered();
// id_019c2f72a841_fxOniKPDBAktptggIajv5DyIjBUOVx92

Time-ordered identifiers contain a Unix timestamp in milliseconds followed by the same 32-character random component.

Composite identifiers

CompositeId combines multiple string values into a single reversible, URL-safe identifier.

var id = new CompositeId( [ "tenant", "resource" ] );
var parsed = CompositeId.Parse( id.ToString() );

Duration

Duration represents a non-negative duration with millisecond precision and supports compact values such as 2h30m and 500ms.

var duration = Duration.FromSeconds( 30 );
Duration.TryParse( "2h30m", out var parsed );

Base64 URL encoding

Base64Encoder produces canonical, unpadded Base64URL strings and accepts both standard Base64 and Base64URL input when decoding.

Object caching

Register an IDistributedCache implementation, then add the object cache:

services.AddDistributedMemoryCache();

services.AddDistributedObjectCache( options =>
{
    options.DefaultAbsoluteExpiration = TimeSpan.FromMinutes( 1 );
    options.DefaultNegativeAbsoluteExpiration = TimeSpan.FromSeconds( 5 );
} );

IObjectCache.GetAsync<T> returns null for a cache miss. A non-null ObjectCacheEntry<T> represents a cached result; IsNegative indicates a cached absence.

var cached = await objectCache.GetAsync<Device>( key, cancellationToken );

if ( cached is not null )
{
    return cached.Value;
}

var device = await repository.GetDeviceAsync( id, cancellationToken );

if ( device is null )
{
    await objectCache.SetNegativeAsync<Device>( key, cancellationToken: cancellationToken );
    return null;
}

await objectCache.SetAsync( key, device, cancellationToken: cancellationToken );
return device;

Use a shared IDistributedCache provider when entries must survive application restarts or be shared between instances.

Cached HTTP clients

Register a named cached client using the normal HttpClient configuration model:

services
    .AddCachedHttpClient( "devices", ( serviceProvider, httpClient ) =>
    {
        httpClient.BaseAddress = new Uri( "https://devices.example/" );
    } )
    .ConfigureCachedHttpClient( options =>
    {
        options.TransientNegativeAbsoluteExpirationRelativeToNow =
            TimeSpan.FromSeconds( 5 );
    } );

Create clients through ICachedHttpClientFactory:

var client = cachedHttpClientFactory.CreateClient( "devices" );

var device = await client.GetAsync<Device>(
    $"device:{deviceId}",
    $"/api/devices/{deviceId}",
    device => device.Enabled,
    cancellationToken
);

GetAsync<T> returns a cached value when available. Missing or unacceptable objects are negatively cached. Selected transient HTTP failures are cached briefly; other failures return null without being cached. Cache failures do not prevent the HTTP lookup from succeeding.

Implement IAuthorizationProvider when requests need dynamic authorization. The provider receives the complete HttpRequestMessage and may apply any authorization scheme, header, query value, or signature.

Cached values are shared by cache key. Do not use a cached client for caller-specific responses unless the cache key includes the relevant tenant, user, or authorization scope.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Faactory.Types:

Package Downloads
Faactory.Channels.Abstractions

Channels

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.1 225 8/10/2026
2.0.0 120 7/30/2026
1.9.1 270 4/30/2026
1.9.0 102 4/30/2026
1.8.1 586 12/4/2024
1.8.0 179 12/3/2024
1.7.1 325 3/4/2024
1.7.0 192 2/29/2024
1.6.0 6,101 8/2/2022
1.5.2 551 7/14/2022
1.5.1 3,425 4/7/2022
1.5.0 1,156 4/7/2022
1.4.4 539 8/19/2021
1.4.3 497 7/6/2021
1.4.2 465 7/6/2021
1.4.1 517 7/6/2021