DKNet.Svc.Transformation
10.1.17
See the version list below for details.
dotnet add package DKNet.Svc.Transformation --version 10.1.17
NuGet\Install-Package DKNet.Svc.Transformation -Version 10.1.17
<PackageReference Include="DKNet.Svc.Transformation" Version="10.1.17" />
<PackageVersion Include="DKNet.Svc.Transformation" Version="10.1.17" />
<PackageReference Include="DKNet.Svc.Transformation" />
paket add DKNet.Svc.Transformation --version 10.1.17
#r "nuget: DKNet.Svc.Transformation, 10.1.17"
#:package DKNet.Svc.Transformation@10.1.17
#addin nuget:?package=DKNet.Svc.Transformation&version=10.1.17
#tool nuget:?package=DKNet.Svc.Transformation&version=10.1.17
DKNet.Svc.Transformation
Template-token substitution: fills bracketed tokens ([Name], {Email}, <Amount>, {{Ref}}) in a string from
a plain object or a IDictionary<string, string>, with pluggable value formatting. Not an object mapper, and not
a template engine — there are no conditionals, loops, or partials.
Features
ITransformerService—Transform/TransformAsynca template against one or more parameter sources- Four built-in token styles (square/curly/angle/double-curly brackets), or define your own pair
- Configurable behaviour when a token cannot be resolved (
ThrowError,LeaveAsIs,Remove) - Pluggable
IValueFormatterfor bool/number/date formatting, invariant-culture by default - Global parameters shared across every template
Installation
dotnet add package DKNet.Svc.Transformation
Quick Start
using DKNet.Svc.Transformation;
using Microsoft.Extensions.DependencyInjection;
builder.Services.AddTransformerService(); // ITransformerService, transient
public sealed class WelcomeEmailBuilder(ITransformerService transformer)
{
public Task<string> BuildAsync(User user) =>
transformer.TransformAsync("Hello [Name], your account [Email] is ready.", user);
}
AddTransformerService(Action<TransformOptions>? optionFactory = null) is the only registration entry point.
It builds one TransformOptions, registers it as IOptions<TransformOptions>, and registers
ITransformerService → TransformerService as transient. It returns immediately if ITransformerService is
already registered, so the first call's options win and a later call's delegate is silently ignored.
Configuration — TransformOptions
Configured in code through the delegate passed to AddTransformerService. There is no IConfiguration binding
path for this package.
| Option | Type | Default | Effect |
|---|---|---|---|
DefaultDefinitions |
ICollection<ITokenDefinition> (get-only) |
[SquareBrackets] |
Bracket styles recognised. Add more; the property has no setter, so square brackets stay active unless you Clear() the collection first. |
Formatter |
IValueFormatter |
new ValueFormatter() |
Converts each resolved value to its display string. |
GlobalParameters |
IEnumerable<object> |
[] |
Fallback resolution sources, tried after the call's own parameters. |
TokenNotFoundBehavior |
TokenNotFoundBehavior |
ThrowError |
ThrowError throws UnResolvedTokenException; LeaveAsIs keeps the token text; Remove substitutes an empty string. |
Built-in definitions, all static readonly on TransformOptions: SquareBrackets ([Token]),
CurlyBrackets ({Token}), AngledBrackets (<Token>), DoubleCurlyBrackets ({{Token}}). Define your own
with new TokenDefinition(begin, end), which throws ArgumentException for a null or whitespace tag.
ValueFormatter is a public class with virtual members — subclass it to change just the formats:
| Property | Type | Default |
|---|---|---|
DateFormat |
string |
"dd/MM/yyyy hh.mm.ss" |
IntegerFormat |
string |
"###,##0" |
NumberFormat |
string |
"###,##0.00" |
bool renders as Yes/No; int/long use IntegerFormat; double/decimal/float use NumberFormat;
DateTime/DateTimeOffset use DateFormat; anything else falls back to ToString(). All formatting runs
against CultureInfo.InvariantCulture.
Public extension points
| Type | Accessibility | Can you supply your own? |
|---|---|---|
ITokenDefinition / TokenDefinition |
public interface / public sealed class | Yes — add to DefaultDefinitions. |
IValueFormatter / ValueFormatter |
public interface / public class with virtual members | Yes — assign Formatter. |
ITransformerService |
public interface | Yes — register your own before calling AddTransformerService. |
ITokenExtractor, ITokenResolver |
public interfaces, internal sealed implementations |
No — TransformerService constructs them itself; nothing reads yours. |
Documentation
Full feature reference, diagrams, and gotchas: https://github.com/baoduy/DKNet/blob/main/docs/Services/DKNet.Svc.Transformation.md
| 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
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Options (>= 10.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.1.19 | 27 | 9/3/2026 |
| 10.1.18 | 30 | 9/3/2026 |
| 10.1.17 | 36 | 9/3/2026 |
| 10.1.16 | 33 | 9/3/2026 |
| 10.1.15 | 67 | 9/1/2026 |
| 10.1.14 | 63 | 9/1/2026 |
| 10.1.13 | 76 | 8/31/2026 |
| 10.1.12 | 89 | 8/25/2026 |
| 10.1.11 | 95 | 8/24/2026 |
| 10.1.10 | 90 | 8/22/2026 |
| 10.1.9 | 100 | 8/22/2026 |
| 10.1.8 | 88 | 8/21/2026 |
| 10.1.7 | 86 | 8/21/2026 |
| 10.1.6 | 89 | 8/21/2026 |
| 10.1.5 | 107 | 8/20/2026 |
| 10.1.4 | 89 | 8/20/2026 |
| 10.1.3 | 99 | 8/19/2026 |
| 10.1.2 | 111 | 8/19/2026 |
| 10.1.1 | 89 | 8/19/2026 |
| 10.0.36 | 101 | 8/18/2026 |