Guides & Recipes — Printing
L3StableNuGet: v1.0.0Local HEAD: v2.0.0AOT: Partial
Verified patterns compiled on .NET 10 (ImplicitUsings=disable, Nullable=enable).
Recipe 1: Keyed Multi-Station Printers (Kitchen + Receipt)
Section titled “Recipe 1: Keyed Multi-Station Printers (Kitchen + Receipt)”using System;using EricksonLopez.Printing;using Microsoft.Extensions.DependencyInjection;
namespace Example.PrintingQuickStart;
public static class KeyedPrinterRecipe{ public static ServiceProvider ConfigureStations() { var services = new ServiceCollection();
services.AddKeyedPooledTcpPrinter("front-desk", options => { options.Host = "192.168.1.200"; options.Port = 9100; options.TimeoutMs = 3000; });
services.AddKeyedTcpPrinter("shipping-zpl", options => { options.Host = "192.168.1.205"; options.Port = 9100; options.TimeoutMs = 5000; });
return services.BuildServiceProvider( new ServiceProviderOptions { ValidateOnBuild = true, ValidateScopes = true }); }}Recipe 2: Wrapping an IPrinterClient with WithRetry (ResilientPrinterClient)
Section titled “Recipe 2: Wrapping an IPrinterClient with WithRetry (ResilientPrinterClient)”using System;using EricksonLopez.Printing;
namespace Example.PrintingQuickStart;
public static class ResilientPrinterRecipe{ public static IPrinterClient CreateResilientClient() { var tcp = new TcpPrinterClient(new TcpPrinterClientOptions { Host = "192.168.1.200", Port = 9100, TimeoutMs = 5000, });
return tcp.WithRetry(options => { options.MaxRetries = 2; options.InitialDelay = TimeSpan.FromMilliseconds(200); }); }}