Architect.AmbientContexts 2.0.0

dotnet add package Architect.AmbientContexts --version 2.0.0                
NuGet\Install-Package Architect.AmbientContexts -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Architect.AmbientContexts" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Architect.AmbientContexts --version 2.0.0                
#r "nuget: Architect.AmbientContexts, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Architect.AmbientContexts as a Cake Addin
#addin nuget:?package=Architect.AmbientContexts&version=2.0.0

// Install Architect.AmbientContexts as a Cake Tool
#tool nuget:?package=Architect.AmbientContexts&version=2.0.0                

Provides the basis for implementing the Ambient Context pattern. Includes a Clock implementation based on it.

The Ambient Context pattern is an Inversion of Control (IoC) pattern that provides static access to a dependency while controlling the dependency from the outside.
The pattern optimizes code reachability at the cost of reduced transparency, making it suitable for obvious, ubiquitous, rarely-changing dependencies.
For example, an entity's constructor can access Clock.UtcNow, avoiding the need to inject the creation datetime or a dependency, at the cost of hiding the fact that a unit test could control the timestamp from the outside.

An example from .NET is System.Transactions.TransactionScope. Any code (such as the database connector) can access the static Transaction.Current, yet outer code in the current execution flow controls it, through TransactionScopes.

Release notes:

- BREAKING: ClockScope no longer has a configurable default scope. (See also next item).
- BREAKING: Removed explicit support for "configured default scopes", i.e. scopes configured on startup. They posed too many concurrency risks, such as in test runs. (Default scopes without any configuration are still supported.)
- BREAKING: Removed the RemoveAmbientScope() method. Deactivate() should be used instead.
- Added support for netstandard2.0.
- ClockScope's constructor now prefers UTC datetimes, to avoid lossy conversions (due to DST).
- ClockScope now exposes a convenience constructor that takes a DateTime instead of a Func<DateTime>.

- Manually disposing scopes from a deeper async level (such as a DisposeAsync() method with the async keyword) now properly affects methods up the call stack and no longer breaks scope nesting.
- Improved the protections against race conditions.
- Parent properties are no longer unset on disposal (although implementations should not rely on this detail).
- Performance improvement: A scope now avoids even instantiating its AsyncLocal as long as only its default scope is used, as is common in production for certain scopes.
- Performance improvement: The JIT can now inline more code, since exceptions have been moved into helper methods.

- Introduced non-generic AmbientScope base class.
- Performance improvement: A scope now avoids touching its AsyncLocal as long as only its default scope is used, as is common in production for certain scopes.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Architect.AmbientContexts:

Package Downloads

Reliable unique ID generation and management for distributed applications. Auto-increment IDs reveal sensitive information. UUIDs (also known as GUIDs) are inefficient as primary keys in a database. Having two different IDs is cumbersome and counterintuitive. We can do better. - For a 93-bit UUID replacement that is efficient as a primary key, use the DistributedId. - For a 128-bit 128-bit UUID replacement with the advantages of the DistributedId and practically no rate limits or collisions, at the cost of more space, use the DistributedId128. - To expose IDs externally in a sensitive environment where zero metadata must be leaked, transform them with PublicIdentities. Release notes: 2.1.0: - Semi-breaking: IPublicIdentityConverter now features additional methods, although the type is generally not user-implemented. - Semi-breaking: HexadecimalIdEncoder's char-based parameters have been renamed from "bytes" to "chars". - Added DistributedId128, a 128-bit (Guid/UInt128) DistributedId variant with practically no rate limits or collisions that also doubles as a version-7 UUID. - Added encoding methods for UInt128. - Added extension methods to transcode between UInt128 and Guid. - Added public identity conversions for UInt128 and Guid. - DistributedIdGeneratorScope and DistributedId128GeneratorScope now expose the CurrentGenerator property, which helps when implementing generators that need to piggyback on the encapsulated generator. 2.0.0: - BREAKING: Removed Fluid. Ambient scopes with startup configuration are now considered undesirable. - BREAKING: Removed ApplicationInstanceId. Ambient scopes with startup configuration are now considered undesirable. - BREAKING: Removed ambient access to IPublicIdentityConverter. Ambient scopes with startup configuration are now considered undesirable. - BREAKING: IdEncoder has been reworked into BinaryIdEncoder, AphanumericIdEncoder, and HexadecimalIdEncoder. - BREAKING: ID decoding methods now throw if the input is too long. This is specially relevant for strings (such as query parameters) where 0123456789123456 and 0123456789123456aaaa should not produce the same ID. - BREAKING: IPublicIdentityConverter now throws on big-endian architectures, instead of risking silent portability issues between architectures. - BREAKING: Now using AmbientContexts 2.0.0. - Semi-breaking: DistributedIds are now always 28 digits, to avoid a change from 27 to 28 digits in the future. Newly generated IDs will be significantly greater than before. Avoid downgrading after upgrading. - DistributedIds can now burst-generate ~128,000 IDs at once before the ~128 IDs per millisecond throttling kicks in. This makes throttling much less likely to be encountered. - DistributedId now stays incremental even under clock adjustments of up to 1 second. (Note that the UTC clock remains unaffected by DST.) - Hexadecimal ID encodings are now supported. - IPublicIdentityConverter now comes with a TestPublicIdentityConverter implementation for unit tests. - Added UnsupportedOSPlatform("browser") to PublicIdentities, due to continuing lack of AES support. 1.0.2: - Now using AmbientContexts 1.1.1, which fixes extremely rare bugs and improves performance. 1.0.1: - Now using AmbientContexts 1.1.0, for a performance improvement.


Manage your DbContexts the right way. The persistence or infrastructure layer uses the DbContext (e.g. from a repository). Controlling its scope and transaction lifetime, however, is ideally the reponsibility of the orchestrating layer (e.g. from an application service). This package adds that ability to Entity Framework Core 5.0.0 and up. Release notes: 2.0.0: - BREAKING: Now using AmbientContexts 2.0.0. - Semi-breaking: Failure on commit (extremely rare) now throws IOException instead of Exception. - Added static DbContextScope<TDbContext>.HasDbContext, to match the feature set of IDbContextAccessor. - Retries now ensure that the connection is closed before retrying, to avoid the risk of leaking session state. (As with EF's DbContext disposal in general, this relies on the database provider's connection reset.) - Scoped execution now protects against dangerous "failure on commit" retries even on manual commits (rather than just on IExecutionScope's implicit commit). - Worked around an EF bug where the DbContext would obscure the exception caused by a broken model behind an ObjectDisposedException, even though DbContext._disposed=false. - Scoped execution: Fixed a bug where the exception caused by a broken model would be obscured behind a wrongful IncompatibleVersionException. - MockDbContextProvider: Fixed a bug where nested scopes would not work as expected. - MockDbContextProvider: Fixed a bug where soft attempts to roll back a transaction when there was none could cause an unintended TransactionAbortedException. 1.0.1: - Now using AmbientContexts 1.1.1, which fixes extremely rare bugs and improves performance.


Contains objects and helpers to help the calculation of objects in 2D-space and time.


Light and dynamic resources for your Blazor WebAssembly website.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 33,814 3/23/2023
1.1.1 54,442 1/1/2022
1.1.0 5,211 9/12/2021
1.0.0 15,961 12/7/2020