DKNet

Register the service

Part of DKNet.Svc.Transformation. AddTransformerService(Action<TransformOptions>?) is the only registration entry point: it builds one TransformOptions, registers it as IOptions<TransformOptions>, and registers ITransformerService → TransformerService as transient.

builder.Services.AddTransformerService(options =>
{
    options.GlobalParameters = [new { CompanyName = "Acme Corp" }];
});

It returns immediately if ITransformerService is already registered — so the first call’s options win and a later call’s configuration delegate is silently ignored.

services.AddTransformerService checks whether ITransformerService is already registered; if not, it builds TransformOptions, invokes the configure delegate, and registers the transient service — otherwise it returns immediately and the delegate never runs.

This does not show what the registered service does per call — see the package 🔄 How it works — or that registering your own ITransformerService implementation before calling AddTransformerService makes it return early too, which is how you can replace the service outright.

Tokens resolve against the call’s own parameters first and fall back to GlobalParameters — the place for values shared by every template the app renders (company name, support address). With no parameters at all, resolution uses GlobalParameters only.

⚙️ Configuration reference

Option Type Default Effect
GlobalParameters IEnumerable<object> [] Fallback resolution sources tried after the call’s own parameters — see fill a template from data.

There is no IConfiguration/appsettings.json binding path for TransformOptions — it is configured entirely through the delegate passed to AddTransformerService.

🧱 Where it fits

AddTransformerService is the host’s one entry point into the package: it owns both the TransformOptions the other features read (token syntax, value formatting) and the ITransformerService registration the host calls into. See the package 🏗️ Architecture diagram for how the registered service relates to the host application.

⚠️ Gotchas & limits