Quick start
On this page
Examples use .NET 10: install TUtility.Core for caches and CRC, TUtility for operation results, and TUtility.App with its generator for modular hosting.
Core tools
dotnet new console -n UtilityDemo -f net10.0
cd UtilityDemo
dotnet add package TUtility.CorePlace this in Program.cs:
using TUtility;
using TUtility.Caching;
using var cache = new MemoryCache<string, string>();
cache.Set("device:P-001", "Pump", expire: 60);
if (cache.TryGetValue("device:P-001", out var name))
{
Console.WriteLine(name);
}
byte[] payload = [0x01, 0x03, 0x00, 0x00, 0x00, 0x02];
var crc = CrcHelper.Crc16Only(payload.AsSpan());
Console.WriteLine(Convert.ToHexString(crc));Run:
dotnet runExpected output:
Pump
C40BCache TTLs use seconds; disposal ends the cleanup timer. CRC returns two checksum bytes without the original payload. Assemble frames and order bytes according to the target protocol.
Operation results
dotnet add package TUtilityusing TUtility;
OperResult<int> result = OperResult.CreateSuccessResult(42);
if (result.IsSuccess)
{
Console.WriteLine(result.Content);
}Replace Program.cs with this fragment and run dotnet run to print 42. OperResult belongs to TUtility rather than Core. Its success-code convention differs from TWebApi’s 200. Check IsSuccess before consuming failed-result content; see results.
Modular hosts
dotnet add package TUtility.App
dotnet add package TUtility.Generator
dotnet add package Microsoft.Extensions.HostingCall the generated AppStartupRunner during service registration and initialization, then run the host. See AppStartup for complete code. Plain utility calls do not require a Host.
Apply the tools in your project
| Task | Chapter | Integration decision |
|---|---|---|
| Cache devices or query results | Caches and pools | TTL units, capacity cleanup and disposal |
| Process operations concurrently | Async coordination | Share a limiter across callers and release each acquired permit |
| Run periodic maintenance | TimerX | Reentrancy, time zone and operations still running at shutdown |
| Exchange JSON data | Serialization | Naming, long integers and required resolvers |
Source: TUtility repository . src contains runtime libraries, analyzer contains analyzers and generators, and test contains examples and tests.