Path: redb/redb.Core/RedbServiceProviders.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/RedbServiceProviders.cs ---- using System; using Microsoft.Extensions.DependencyInjection; namespace redb.Core; /// /// Whether a service provider is the root of its container - the one whose lifetime is the container's. A service /// resolved from it is captive: it lives as long as the process and the ambient frame it enters is inherited by every /// flow. Such a service lends lazy loads its scope factory, never its one connection (review after 4.0.0, finding 4; /// owner decision 2026-09-17): a lazy load resolved to a captive reader runs in a fresh scope of its container. /// /// Microsoft.Extensions.DependencyInjection: the root scope's provider is its own , /// a child scope's is not (pinned by a unit test). Another container is not recognised: its services are never captive. /// /// public static class RedbServiceProviders { /// True when is the root provider of a Microsoft DI container. public static bool IsRoot(IServiceProvider serviceProvider) { ArgumentNullException.ThrowIfNull(serviceProvider); return ReferenceEquals(serviceProvider, serviceProvider.GetService()); } }