Skip to content

Compono.CompositionRowServiceProviderExtensions

Compono.DependencyInjection

Compono

CompositionRowServiceProviderExtensions Class

The one public entry point of Compono.DependencyInjection - a configured-resolution System.IServiceProvider bridge over a CompositionRow. See docs/adr/0047-compono-dependencyinjection-configured-resolution-bridge.md.

public static class CompositionRowServiceProviderExtensions

Inheritance System.Object → CompositionRowServiceProviderExtensions

Methods
AsServiceProvider(this CompositionRow) Wraps row as an System.IServiceProvider backed by TryResolveConfigured(Type, object), with stable per-System.Type identity for the lifetime of the returned instance: the first successful resolution for a given type is cached, and every later GetService call for that same type returns the identical instance - this is what lets a test configure a double once and have a separately-rendered consumer (e.g. a bUnit component's [Inject]) observe the same value. A miss is never cached - a type unsatisfiable on one call can still be satisfied by a later one, if the row's own configuration changes in between. Calling this more than once for the same row returns the identical System.IServiceProvider instance every time, not a fresh one - this is what makes the whole surface, including concurrent GetService calls made through two separately-obtained references, safe to use concurrently: no corruption, no torn state, no two same-type callers ever observing different instances. It is NOT a promise that which of two DIFFERENT types resolves first is itself deterministic when both are requested concurrently for the first time - see the concurrency remark below for what that means for randomness-dependent factories/providers.