Codebelt

Cuemon.Core

Foundational utilities extending the System namespace with factories, collections, time types, non-cryptographic hashing, reflection, runtime abstractions, and globalization data.

.NET 10.0 / .NET 9.0 MIT v10.5.3 548,587 downloads

Overview

Cuemon.Core builds on Cuemon.Kernel and fills out the broader Cuemon namespace with concrete utilities for parsing, formatting, delegate invocation, date and range calculations, reflection, runtime monitoring, diagnostics, globalization data, and non-cryptographic hashing.

The package mixes static entry points such as DelimitedString, ParserFactory, HashFactory, and World with reusable types such as DateSpan, ExceptionDescriptor, CorrelationToken, RequestToken, and Watcher. That makes it the general-purpose core layer for applications and libraries that need more than the lower-level abstractions in Cuemon.Kernel, but not the framework-specific integrations from sibling packages.

Key APIs

ActionFactory<TTuple> and FuncFactory<TTuple, TResult> wrap delegates together with a MutableTuple argument object. They let consumers execute strongly typed Action and Func pipelines with many parameters without creating one-off wrapper types for each signature.

DelimitedString creates delimited output with Create<T> and splits delimited input with Split. DelimitedStringOptions and DelimitedStringOptions<T> control delimiters, qualifiers, and conversion, and the splitter throws when malformed qualified input cannot be processed safely.

DateSpan models a calendar-aware interval between two DateTime values. It exposes component values such as Years, Months, Days, and GetWeeks() alongside total values, and its Parse overloads create spans directly from string representations.

ParserFactory builds IParser and IConfigurableParser implementations for common conversions such as GUIDs, Base64, hexadecimal, URI schemes, enums, URIs, and value types. The factory methods keep parsing behavior explicit by pushing format-specific rules into option objects instead of ad hoc string handling.

ExceptionDescriptor turns an Exception into a structured object with Code, Message, HelpLink, Failure, and an evidence dictionary. Extract creates a default descriptor from an exception, and PostInitializeWith applies ExceptionDescriptorAttribute metadata after construction.

ActivatorFactory and AssemblyContext cover reflective runtime tasks. ActivatorFactory.CreateInstance offers strongly typed overloads from zero to five constructor arguments, while AssemblyContext.GetCurrentDomainAssemblies uses AssemblyContextOptions to include or filter current-domain and referenced assemblies.

HashFactory creates CRC and Fowler-Noll-Vo hash implementations through a single static entry point. The returned Hash instances compute hashes from strings, streams, byte arrays, and other convertible inputs, and HashResult exposes byte, hexadecimal, Base64, URL-safe Base64, and binary representations.

World exposes region and UN M.49 statistical data through Regions, StatisticalRegions, GetStatisticalRegion, GetCountry, and GetCultures. It gives consumers a bridge between .NET RegionInfo, country identifiers, and statistical-region hierarchies without maintaining their own lookup tables.

PaginationEnumerable<T>, PaginationList<T>, PartitionerEnumerable<T>, and PartitionerCollection<T> handle paging and partitioning over sequences. They expose page-state and partition-state members such as PageCount, HasNextPage, PartitionsCount, IteratedCount, and Remaining so batching logic stays explicit.

Basic usage

using System;
using Codebelt.Extensions.Xunit;
using Cuemon;
using Xunit;

namespace MyProject.Tests;

public class DelimitedStringUsageTest : Test
{
    public DelimitedStringUsageTest(ITestOutputHelper output) : base(output)
    {
    }

    [Fact]
    public void ShouldSplitDigestChallengeWithoutBreakingQuotedValues()
    {
        var challenge = "realm=\"unittest\", qop=\"auth, auth-int\", nonce=\"MjAyMC0xMC0yMCAyMzoxMzo0MFo6OWY1NmRjZTY0NWI3YjY5YjhlM2NlOTFhNDM2ZWI2ZGFiNDIxYzY5MjU4YzI1YTBkNDg1M2RkYTQ2NmRkOWJkNg==\"";
        var parts = DelimitedString.Split(challenge);

        Assert.Equal(3, parts.Length);
        Assert.Equal(" qop=\"auth, auth-int\"", parts[1]);
        TestOutput.WriteLine(string.Join(Environment.NewLine, parts));
    }
}

Use this pattern when you need to consume CSV-like or header-like text where separators may appear inside qualified values and surrounding whitespace should remain intact. It matters because DelimitedString.Split honors the configured delimiter and qualifier rules and fails when the input cannot be split safely.

Installation

dotnet add package Cuemon.Core

Usage guidance

Use Cuemon.Core when you need reusable infrastructure primitives above Cuemon.Kernel, especially for parsing and formatting, calendar-aware spans, reflective construction, assembly discovery, structured exception metadata, UN M.49 region lookups, or CRC and FNV hashing. If you only need the lower-level abstractions and guards from Cuemon.Kernel, stay with that package; if you need framework integrations such as ASP.NET Core, dependency injection, or cryptographic hashing, move to the more focused sibling packages.

Family packages