Table of Contents

Class TcgDexServiceCollectionExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
TcgDex.CSharpSdk.dll

Registers the TCGdex client with a dependency-injection container.

public static class TcgDexServiceCollectionExtensions

Inheritance

Inherited Members

Methods

AddTcgDex(IServiceCollection, Action<TcgDexOptions>?)

Registers TcgDex.ITcgDexClient and its backing System.Net.Http.HttpClient.

public static IHttpClientBuilder AddTcgDex(this IServiceCollection services, Action<TcgDexOptions>? configure = null)

Parameters

services IServiceCollection

The container to add to.

configure Action<TcgDexOptions>?

Optional configuration; defaults target the official host in English.

Returns

IHttpClientBuilder

The Microsoft.Extensions.DependencyInjection.IHttpClientBuilder for the underlying client, so callers can attach their own handlers or resilience policies.

Remarks

Registered through IHttpClientFactory so handler lifetime and connection pooling are managed correctly. Constructing System.Net.Http.HttpClient by hand per call is the usual cause of socket exhaustion in SDK consumers.

Exceptions

ArgumentNullException

services is null.

AddTcgDexWithCaching(IServiceCollection, Action<TcgDexOptions>?, Action<TcgDexCacheOptions>?)

Registers TcgDex.ITcgDexClient with response caching enabled.

public static IHttpClientBuilder AddTcgDexWithCaching(this IServiceCollection services, Action<TcgDexOptions>? configure = null, Action<TcgDexCacheOptions>? configureCache = null)

Parameters

services IServiceCollection

The container to add to.

configure Action<TcgDexOptions>?

Optional client configuration.

configureCache Action<TcgDexCacheOptions>?

Optional cache policy.

Returns

IHttpClientBuilder

The Microsoft.Extensions.DependencyInjection.IHttpClientBuilder for the underlying client, so callers can attach further handlers.

Remarks

Caching is opt-in because the API sends Cache-Control: no-store, so enabling it is a decision about your own tolerance for stale data rather than something the service asks for.

It is worth enabling: the API honours If-None-Match, so once an entry falls out of its freshness window it is revalidated rather than re-fetched. An unchanged 22 KB set response then costs a 304 and zero bytes of body.

Register your own TcgDex.Caching.ITcgDexResponseCache before calling this to back the cache with something shared or persistent; otherwise a bounded in-process cache is used.

Exceptions

ArgumentNullException

services is null.