SquidStd.Core
0.8.0
dotnet add package SquidStd.Core --version 0.8.0
NuGet\Install-Package SquidStd.Core -Version 0.8.0
<PackageReference Include="SquidStd.Core" Version="0.8.0" />
<PackageVersion Include="SquidStd.Core" Version="0.8.0" />
<PackageReference Include="SquidStd.Core" />
paket add SquidStd.Core --version 0.8.0
#r "nuget: SquidStd.Core, 0.8.0"
#:package SquidStd.Core@0.8.0
#addin nuget:?package=SquidStd.Core&version=0.8.0
#tool nuget:?package=SquidStd.Core&version=0.8.0
<p align="center"> <img src="https://raw.githubusercontent.com/tgiachi/squid-std/main/assets/icon.png" alt="SquidStd" width="120" height="120" /> </p>
<h1 align="center">SquidStd.Core</h1>
<p align="center"> <a href="https://www.nuget.org/packages/SquidStd.Core/"><img src="https://img.shields.io/nuget/v/SquidStd.Core.svg" alt="NuGet" /></a> <img src="https://img.shields.io/nuget/dt/SquidStd.Core.svg" alt="Downloads" /> <a href="https://tgiachi.github.io/squid-std/articles/core.html"><img src="https://img.shields.io/badge/docs-DocFX-1390A3.svg" alt="docs" /></a> <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license" /> </p>
Foundational contracts and utilities for the SquidStd stack. It defines the core service interfaces (configuration, event bus, jobs, timing, metrics, storage) and ships dependency-free helpers — YAML/JSON serialization, a Serilog event sink, and string/environment/directory extensions — that the other SquidStd packages build on.
Install
dotnet add package SquidStd.Core
Features
- Configuration contracts:
IConfigEntry(a YAML section) andIConfigManagerService. - In-process messaging:
IEventBuswithISyncEventListener<T>/IAsyncEventListener<T>overIEvent. - Command dispatch:
ICommandDispatcher<TContext>withICommandHandler<TCommand,TContext>, fan-out, fault isolation, and aCommandDispatchResult;ICommandContextFactory<TContext,TSeed>builds the context from a seed forISeededCommandDispatcher<TContext,TSeed>. - Background work & timing:
IJobSystem,ITimerService,IMainThreadDispatcher. - Metrics & secrets:
IMetricProviderand secret-protection contracts. - Serialization:
IDataSerializer/IDataDeserializer(defaultJsonDataSerializer), plusYamlUtils/JsonUtils. - File watching:
IFileWatcherService/FileWatcherService— recursive, debounced watchers that publishFileChangedEventon the event bus. - Object pooling:
ObjectPool<T>— thread-safe, non-blocking, factory-based reuse with optional reset. - Cryptography:
CryptoUtils(AES-GCM authenticated encrypt/decrypt + key generation),EncryptString/DecryptStringstring helpers, base64 extensions, andSslUtilsfor loading PEM/PFX TLS certificates. - Randomness:
BuiltInRng(seedable ambient RNG),RandomUtils(dice, coin flips), and collectionShuffle/RandomElement/RandomSampleextensions. - Utilities: a Serilog
EventSink, and string/env/directory extensions. - Shared domain enums under
Types(e.g.LogLevelType,PlatformType,FileChangeKind).
Usage
using SquidStd.Core.Extensions.Env;
using SquidStd.Core.Yaml;
// Expand "$VAR" tokens against the environment (unknown vars are left untouched).
var path = "$HOME/squidstd/data".ReplaceEnv();
// Serialize / deserialize YAML.
var yaml = YamlUtils.Serialize(new { name = "squid", port = 9000 });
using SquidStd.Core.Files;
using SquidStd.Core.Data.Files;
using SquidStd.Core.Pool;
// Watch several directories (each with its own glob) and react via the event bus.
// Via DI: container.RegisterFileWatcherService(); then resolve IFileWatcherService.
var watcher = new FileWatcherService(eventBus);
watcher.Watch("data/scripts", "*.lua");
watcher.Watch("data/templates", "*.json");
eventBus.Subscribe<FileChangedEvent>((change, _) =>
{
Console.WriteLine($"{change.Kind}: {change.FullPath}");
return Task.CompletedTask;
});
// Reuse short-lived buffers instead of allocating per call.
using var pool = new ObjectPool<StringBuilder>(() => new StringBuilder(), onReturn: sb => sb.Clear());
var builder = pool.Get();
// ... use builder ...
pool.Return(builder);
Key types
| Type | Purpose |
|---|---|
IConfigEntry |
A registrable YAML configuration section. |
IConfigManagerService |
Loads YAML config and exposes typed sections. |
IEventBus |
Publish/subscribe in-process event bus. |
IJobSystem |
Background job scheduling/execution. |
ITimerService |
Timer-wheel based scheduling. |
IMetricProvider |
Source of metric samples for collection. |
IStorageService |
File/object storage abstraction. |
IFileWatcherService |
Recursive, debounced file watcher publishing to the event bus. |
ObjectPool<T> |
Thread-safe, non-blocking object pool. |
ICommandDispatcher<TContext> |
Typed protocol command dispatch with context. |
License
MIT — part of SquidStd.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- DryIoc.dll (>= 5.4.3)
- Serilog (>= 4.3.1)
- YamlDotNet (>= 18.1.0)
NuGet packages (18)
Showing the top 5 NuGet packages that depend on SquidStd.Core:
| Package | Downloads |
|---|---|
|
SquidStd.Abstractions
Package Description |
|
|
SquidStd.Services.Core
Package Description |
|
|
SquidStd.Plugin.Abstractions
Package Description |
|
|
SquidStd.Network
Package Description |
|
|
SquidStd.Messaging.Abstractions
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.